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 index 87d9ba2c7da..6182382b882 100644 --- 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 @@ -1,5 +1,8 @@ -- drop column projects in servers table ALTER TABLE servers DROP COLUMN projects; +-- drop table org_users +DROP TABLE IF EXISTS org_users; + -- 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 index 6307953df05..0d7ad50c908 100644 --- 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 @@ -16,3 +16,13 @@ CREATE TABLE IF NOT EXISTS users ( UNIQUE(infra_server_username,server_id) ); CREATE INDEX IF NOT EXISTS users_automate_user_id_index ON users (automate_user_id); + +-- create table org_users +CREATE TABLE IF NOT EXISTS org_users ( + id TEXT PRIMARY KEY, + org_id TEXT NOT NULL references orgs(id) ON DELETE RESTRICT, + user_id TEXT NOT NULL references users(id) ON DELETE RESTRICT, + is_admin BOOLEAN NOT NULL DEFAULT FALSE +); +CREATE INDEX IF NOT EXISTS org_users_org_id_index ON org_users (org_id); +CREATE INDEX IF NOT EXISTS org_users_user_id_index ON org_users (user_id);