-
Notifications
You must be signed in to change notification settings - Fork 887
chore: move default everyone group to a migration #12435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
||
_, err = q.InsertAllUsersGroup(context.Background(), defaultOrg.ID) | ||
if err != nil { | ||
panic(fmt.Errorf("failed to create default group: %w", err)) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dbmem doesn't have the concept of "migrations". I wonder if we should have something similar rather than chucking them here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think "migrations" is the right concept, since we don't ever change an old dbmem into a new one, but it might make sense to have an abstraction that populates the initial contents of the database, which is what this does...
|
||
_, err = q.InsertAllUsersGroup(context.Background(), defaultOrg.ID) | ||
if err != nil { | ||
panic(fmt.Errorf("failed to create default group: %w", err)) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think "migrations" is the right concept, since we don't ever change an old dbmem into a new one, but it might make sense to have an abstraction that populates the initial contents of the database, which is what this does...
'Everyone', | ||
-- Org ID and group ID must match. | ||
(SELECT id FROM organizations WHERE is_default = true LIMIT 1), | ||
(SELECT id FROM organizations WHERE is_default = true LIMIT 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is LIMIT 1
required for SQL to correctly cast a rowset into a scaler? The unique index on is_default
should ensure there is exactly one organization where it is true
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not required, the unique index should protect this.
I added the LIMIT 1
for defensive programming in our migrations since they can prevent boot of Coderd.
No description provided.