diff --git a/components/infra-proxy-service/storage/postgres/migration/sql/05_user_management.down.sql b/components/infra-proxy-service/storage/postgres/migration/sql/05_user_management.down.sql new file mode 100644 index 00000000000..87d9ba2c7da --- /dev/null +++ b/components/infra-proxy-service/storage/postgres/migration/sql/05_user_management.down.sql @@ -0,0 +1,5 @@ +-- drop column projects in servers table +ALTER TABLE servers DROP COLUMN projects; + +-- drop table users +DROP TABLE IF EXISTS users; diff --git a/components/infra-proxy-service/storage/postgres/migration/sql/05_user_management.up.sql b/components/infra-proxy-service/storage/postgres/migration/sql/05_user_management.up.sql new file mode 100644 index 00000000000..6307953df05 --- /dev/null +++ b/components/infra-proxy-service/storage/postgres/migration/sql/05_user_management.up.sql @@ -0,0 +1,18 @@ +-- add projects column +ALTER TABLE servers ADD COLUMN projects TEXT[] NOT NULL DEFAULT '{}'; + +-- create table users +CREATE TABLE IF NOT EXISTS users ( + id TEXT PRIMARY KEY, + server_id TEXT NOT NULL references servers(id) ON DELETE RESTRICT, + infra_server_username TEXT NOT NULL DEFAULT '', + credential_id TEXT NOT NULL DEFAULT '', + connector TEXT NOT NULL DEFAULT 'local', + automate_user_id TEXT NOT NULL DEFAULT '', + is_server_admin BOOLEAN NOT NULL DEFAULT FALSE, + created_at TIMESTAMPTZ NOT NULL, + updated_at TIMESTAMPTZ NOT NULL, + CONSTRAINT infra_server_username_server_id_key + UNIQUE(infra_server_username,server_id) +); +CREATE INDEX IF NOT EXISTS users_automate_user_id_index ON users (automate_user_id);