From 9792c38de0e69b092de14cd6bd262e10a36fa1c2 Mon Sep 17 00:00:00 2001 From: Rowan Seymour Date: Mon, 24 Feb 2025 14:52:59 -0500 Subject: [PATCH] Lookup system user via email instead of username --- backends/rapidpro/schema.sql | 2 +- backends/rapidpro/testdata.sql | 2 +- backends/rapidpro/user.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/backends/rapidpro/schema.sql b/backends/rapidpro/schema.sql index ee3c3b97..ed5944ec 100644 --- a/backends/rapidpro/schema.sql +++ b/backends/rapidpro/schema.sql @@ -1,7 +1,7 @@ DROP TABLE IF EXISTS users_user CASCADE; CREATE TABLE users_user ( id serial primary key, - username character varying(254) NOT NULL, + email character varying(254) NOT NULL, first_name character varying(150) NOT NULL ); diff --git a/backends/rapidpro/testdata.sql b/backends/rapidpro/testdata.sql index a7b300a7..cd7af4ed 100644 --- a/backends/rapidpro/testdata.sql +++ b/backends/rapidpro/testdata.sql @@ -1,5 +1,5 @@ DELETE FROM users_user; -INSERT INTO users_user("id", "username", "first_name") VALUES(1, 'system', 'System'); +INSERT INTO users_user("id", "email", "first_name") VALUES(1, 'system', 'System'); /* Org with id 1 */ DELETE FROM orgs_org; diff --git a/backends/rapidpro/user.go b/backends/rapidpro/user.go index 420e2cab..26794d37 100644 --- a/backends/rapidpro/user.go +++ b/backends/rapidpro/user.go @@ -12,7 +12,7 @@ type UserID int // gets the system user to use for contact audit fields func getSystemUserID(ctx context.Context, db *sqlx.DB) (UserID, error) { var id UserID - err := db.GetContext(ctx, &id, "SELECT id FROM users_user WHERE username = 'system'") + err := db.GetContext(ctx, &id, "SELECT id FROM users_user WHERE email = 'system'") if err != nil { return 0, fmt.Errorf("error looking up system user: %w", err) }