From 5c85ac67e363c35c3b7622e7ca0ae05752e7b113 Mon Sep 17 00:00:00 2001 From: Wreck-X Date: Thu, 17 Oct 2024 21:18:00 +0530 Subject: [PATCH 1/2] adding migrations for discord id --- migrations/20241017154637_add_discord_id_field.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 migrations/20241017154637_add_discord_id_field.sql diff --git a/migrations/20241017154637_add_discord_id_field.sql b/migrations/20241017154637_add_discord_id_field.sql new file mode 100644 index 0000000..c0e95cc --- /dev/null +++ b/migrations/20241017154637_add_discord_id_field.sql @@ -0,0 +1 @@ +ALTER TABLE Member ADD COLUMN discord_id TEXT; \ No newline at end of file From eab97281bcddfe2c93e6a9ab8f0c929ccc6d4aa5 Mon Sep 17 00:00:00 2001 From: Vishnu Tejas Date: Thu, 17 Oct 2024 21:47:09 +0530 Subject: [PATCH 2/2] changes for adding discord_id --- src/db/member.rs | 1 + src/graphql/mutations.rs | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/db/member.rs b/src/db/member.rs index 52970f1..36abbc9 100644 --- a/src/db/member.rs +++ b/src/db/member.rs @@ -14,4 +14,5 @@ pub struct Member { pub sex: String, pub year: i32, pub macaddress: String, + pub discord_id: String, } diff --git a/src/graphql/mutations.rs b/src/graphql/mutations.rs index dda1dfe..b3f6d41 100644 --- a/src/graphql/mutations.rs +++ b/src/graphql/mutations.rs @@ -29,6 +29,7 @@ impl MutationRoot { sex: String, year: i32, macaddress: String, + discord_id: String, ) -> Result { let pool = ctx.data::>().expect("Pool not found in context"); @@ -36,7 +37,7 @@ impl MutationRoot { let member = sqlx::query_as::<_, Member>( - "INSERT INTO Member (rollno, name, hostel, email, sex, year, macaddress) VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING *" + "INSERT INTO Member (rollno, name, hostel, email, sex, year, macaddress, discord_id) VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING *" ) .bind(rollno) .bind(name) @@ -45,6 +46,7 @@ impl MutationRoot { .bind(sex) .bind(year) .bind(macaddress) + .bind(discord_id) .fetch_one(pool.as_ref()) .await?;