-
Notifications
You must be signed in to change notification settings - Fork 979
chore: add organization_id column to provisioner daemons #12356
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE provisioner_daemons | ||
DROP COLUMN organization_id; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
-- At the time of this migration, only 1 org is expected in a deployment. | ||
-- In the future when multi-org is more common, there might be a use case | ||
-- to allow a provisioner to be associated with multiple orgs. | ||
ALTER TABLE provisioner_daemons | ||
ADD COLUMN organization_id UUID REFERENCES organizations(id) ON DELETE CASCADE; | ||
|
||
UPDATE | ||
provisioner_daemons | ||
SET | ||
-- Default to the first org | ||
organization_id = (SELECT id FROM organizations WHERE is_default = true LIMIT 1 ); | ||
|
||
ALTER TABLE provisioner_daemons | ||
ALTER COLUMN organization_id SET NOT NULL; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we still need to explicitly put this stuff in a transaction? Otherwise a concurrent insert of a provisioner daemon could cause this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, by default all migrations run in a tx now. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 think you've already noticed that this will fail if the default organization hasn't been created. So think we need have a migration that creates a default org if none exists before we can have this.
Uh oh!
There was an error while loading. Please reload this page.
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.
Yea, I will make sure this PR is merged first: #12412