From f616af187bec17bb02e5ab9e2c27164707d36345 Mon Sep 17 00:00:00 2001 From: sonali523 <86949270+sonali523@users.noreply.github.com> Date: Thu, 16 Sep 2021 17:13:32 +0530 Subject: [PATCH] Script added for table 'users' (#5722) * Script added for table 'users' Signed-off-by: root * updated down script Signed-off-by: root * updated up script Signed-off-by: root * updated up script Signed-off-by: root --- .../migration/sql/05_user_management.down.sql | 5 +++++ .../migration/sql/05_user_management.up.sql | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 components/infra-proxy-service/storage/postgres/migration/sql/05_user_management.down.sql create mode 100644 components/infra-proxy-service/storage/postgres/migration/sql/05_user_management.up.sql 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);