Skip to content

Commit 9792c38

Browse files
committed
Lookup system user via email instead of username
1 parent 4ec4a66 commit 9792c38

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

Diff for: backends/rapidpro/schema.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
DROP TABLE IF EXISTS users_user CASCADE;
22
CREATE TABLE users_user (
33
id serial primary key,
4-
username character varying(254) NOT NULL,
4+
email character varying(254) NOT NULL,
55
first_name character varying(150) NOT NULL
66
);
77

Diff for: backends/rapidpro/testdata.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
DELETE FROM users_user;
2-
INSERT INTO users_user("id", "username", "first_name") VALUES(1, 'system', 'System');
2+
INSERT INTO users_user("id", "email", "first_name") VALUES(1, 'system', 'System');
33

44
/* Org with id 1 */
55
DELETE FROM orgs_org;

Diff for: backends/rapidpro/user.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type UserID int
1212
// gets the system user to use for contact audit fields
1313
func getSystemUserID(ctx context.Context, db *sqlx.DB) (UserID, error) {
1414
var id UserID
15-
err := db.GetContext(ctx, &id, "SELECT id FROM users_user WHERE username = 'system'")
15+
err := db.GetContext(ctx, &id, "SELECT id FROM users_user WHERE email = 'system'")
1616
if err != nil {
1717
return 0, fmt.Errorf("error looking up system user: %w", err)
1818
}

0 commit comments

Comments
 (0)