Skip to content

Commit d8e9500

Browse files
authored
chore: add theme_preference column to users table (#11069)
1 parent ebd6c1b commit d8e9500

10 files changed

+55
-30
lines changed

coderd/database/dump.sql

+4-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE users DROP COLUMN "theme_preference";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ALTER TABLE users ADD COLUMN "theme_preference" text NOT NULL DEFAULT '';
2+
3+
COMMENT ON COLUMN "users"."theme_preference" IS '"" can be interpreted as "the user does not care", falling back to the default theme';

coderd/database/migrations/create_migration.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/env bash
22

33
# Usage:
4-
# ./create_migration name of migration
5-
# ./create_migration "name of migration"
6-
# ./create_migration name_of_migration
4+
# ./create_migration.sh name of migration
5+
# ./create_migration.sh "name of migration"
6+
# ./create_migration.sh name_of_migration
77

88
set -euo pipefail
99

@@ -27,7 +27,7 @@ CREATE TYPE new_logintype AS ENUM (
2727
2828
ALTER TABLE users
2929
ALTER COLUMN login_type DROP DEFAULT, -- if the column has a default, it must be dropped first
30-
ALTER COLUMN login_type TYPE new_logintype USING (login_type::text::new_logintype), -- converts the old enum until the new enum using text as an intermediary
30+
ALTER COLUMN login_type TYPE new_logintype USING (login_type::text::new_logintype), -- converts the old enum into the new enum using text as an intermediary
3131
ALTER COLUMN login_type SET DEFAULT 'password'::new_logintype; -- re-add the default using the new enum
3232
3333
DROP TYPE login_type;

coderd/database/modelmethods.go

+13-12
Original file line numberDiff line numberDiff line change
@@ -332,18 +332,19 @@ func ConvertUserRows(rows []GetUsersRow) []User {
332332
users := make([]User, len(rows))
333333
for i, r := range rows {
334334
users[i] = User{
335-
ID: r.ID,
336-
Email: r.Email,
337-
Username: r.Username,
338-
HashedPassword: r.HashedPassword,
339-
CreatedAt: r.CreatedAt,
340-
UpdatedAt: r.UpdatedAt,
341-
Status: r.Status,
342-
RBACRoles: r.RBACRoles,
343-
LoginType: r.LoginType,
344-
AvatarURL: r.AvatarURL,
345-
Deleted: r.Deleted,
346-
LastSeenAt: r.LastSeenAt,
335+
ID: r.ID,
336+
Email: r.Email,
337+
Username: r.Username,
338+
HashedPassword: r.HashedPassword,
339+
CreatedAt: r.CreatedAt,
340+
UpdatedAt: r.UpdatedAt,
341+
Status: r.Status,
342+
RBACRoles: r.RBACRoles,
343+
LoginType: r.LoginType,
344+
AvatarURL: r.AvatarURL,
345+
Deleted: r.Deleted,
346+
LastSeenAt: r.LastSeenAt,
347+
ThemePreference: r.ThemePreference,
347348
}
348349
}
349350

coderd/database/modelqueries.go

+1
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ func (q *sqlQuerier) GetAuthorizedUsers(ctx context.Context, arg GetUsersParams,
316316
&i.Deleted,
317317
&i.LastSeenAt,
318318
&i.QuietHoursSchedule,
319+
&i.ThemePreference,
319320
&i.Count,
320321
); err != nil {
321322
return nil, err

coderd/database/models.go

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries.sql.go

+25-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)