mirror of
https://github.com/coder/coder.git
synced 2025-07-06 15:41:45 +00:00
Migrations
Exclude system users from users.sql queries Signed-off-by: Danny Kopping <danny@coder.com>
This commit is contained in:
4
coderd/database/migrations/000289_system_user.down.sql
Normal file
4
coderd/database/migrations/000289_system_user.down.sql
Normal file
@ -0,0 +1,4 @@
|
||||
ALTER TABLE users
|
||||
DROP COLUMN IF EXISTS is_system;
|
||||
|
||||
DROP INDEX IF EXISTS user_is_system_idx;
|
6
coderd/database/migrations/000289_system_user.up.sql
Normal file
6
coderd/database/migrations/000289_system_user.up.sql
Normal file
@ -0,0 +1,6 @@
|
||||
ALTER TABLE users
|
||||
ADD COLUMN is_system bool DEFAULT false;
|
||||
|
||||
CREATE INDEX user_is_system_idx ON users USING btree (is_system);
|
||||
|
||||
COMMENT ON COLUMN users.is_system IS 'Determines if a user is a system user, and therefore cannot login or perform normal actions';
|
7
coderd/database/migrations/000290_prebuilds.down.sql
Normal file
7
coderd/database/migrations/000290_prebuilds.down.sql
Normal file
@ -0,0 +1,7 @@
|
||||
-- Revert prebuild views
|
||||
DROP VIEW IF EXISTS workspace_prebuild_builds;
|
||||
DROP VIEW IF EXISTS workspace_prebuilds;
|
||||
|
||||
-- Revert user operations
|
||||
DELETE FROM user_status_changes WHERE user_id = 'c42fdf75-3097-471c-8c33-fb52454d81c0';
|
||||
DELETE FROM users WHERE id = 'c42fdf75-3097-471c-8c33-fb52454d81c0';
|
14
coderd/database/migrations/000290_prebuilds.up.sql
Normal file
14
coderd/database/migrations/000290_prebuilds.up.sql
Normal file
@ -0,0 +1,14 @@
|
||||
-- TODO: using "none" for login type produced this error: 'unsafe use of new value "none" of enum type login_type' -> not sure why
|
||||
INSERT INTO users (id, email, username, name, created_at, updated_at, status, rbac_roles, hashed_password, is_system)
|
||||
VALUES ('c42fdf75-3097-471c-8c33-fb52454d81c0', 'prebuilds@system', 'prebuilds', 'Prebuilds Owner', now(), now(),
|
||||
'active', '{}', 'none', true);
|
||||
|
||||
CREATE VIEW workspace_prebuilds AS
|
||||
SELECT *
|
||||
FROM workspaces
|
||||
WHERE owner_id = 'c42fdf75-3097-471c-8c33-fb52454d81c0';
|
||||
|
||||
CREATE VIEW workspace_prebuild_builds AS
|
||||
SELECT workspace_id
|
||||
FROM workspace_builds
|
||||
WHERE initiator_id = 'c42fdf75-3097-471c-8c33-fb52454d81c0';
|
@ -0,0 +1 @@
|
||||
CREATE TABLE
|
Reference in New Issue
Block a user