taskcafe/api/migrations/0044_add-owner-to-team-table.up.sql

5 lines
236 B
SQL

ALTER TABLE team ADD COLUMN owner uuid REFERENCES user_account(user_id) ON DELETE
CASCADE;
UPDATE team SET owner = (SELECT user_id FROM user_account WHERE role_code = 'admin' LIMIT 1);
ALTER TABLE team ALTER COLUMN owner SET NOT NULL;