Skip to content

Commit

Permalink
add-macaddress-field-to-members-table
Browse files Browse the repository at this point in the history
  • Loading branch information
Wreck-X committed Aug 14, 2024
1 parent 5883aa2 commit 453bdd4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion migrations/20240813130838_rename_present_to_isPresent.sql
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ALTER TABLE Attendance RENAME COLUMN ispresent TO is_present;
ALTER TABLE Attendance RENAME COLUMN ispresent TO is_prresent;
2 changes: 1 addition & 1 deletion migrations/20240813132052_rename_present_to_is_present.sql
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ALTER TABLE Attendance RENAME COLUMN ispresent TO is_present;

1 change: 1 addition & 0 deletions src/db/member.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ pub struct Member {
pub email: String,
pub sex: String,
pub year: i32,
pub macaddress: String,
}
6 changes: 4 additions & 2 deletions src/graphql/mutations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,21 @@ impl MutationRoot {
hostel: String,
email: String,
sex: String,
year: i32
year: i32,
macaddress: String,
) -> Result<Member, sqlx::Error> {
let pool = ctx.data::<Arc<PgPool>>().expect("Pool not found in context");

let member = sqlx::query_as::<_, Member>(
"INSERT INTO Member (rollno, name, hostel, email, sex, year) VALUES ($1, $2, $3, $4, $5, $6) RETURNING *"
"INSERT INTO Member (rollno, name, hostel, email, sex, year, macaddress) VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING *"
)
.bind(rollno)
.bind(name)
.bind(hostel)
.bind(email)
.bind(sex)
.bind(year)
.bind(macaddress)
.fetch_one(pool.as_ref())
.await?;

Expand Down

0 comments on commit 453bdd4

Please sign in to comment.