chore: add organization_id column to provisioner daemons (#12356)

* chore: add organization_id column to provisioner daemons
* Update upsert to include organization id on set
This commit is contained in:
Steven Masley
2024-03-06 12:04:50 -06:00
committed by GitHub
parent 46a2ff1061
commit b5f866c1cb
10 changed files with 91 additions and 44 deletions

View File

@ -0,0 +1,2 @@
ALTER TABLE provisioner_daemons
DROP COLUMN organization_id;

View File

@ -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;