Skip to content

Commit

Permalink
Database script for migration tables (#6500)
Browse files Browse the repository at this point in the history
* Script added for migration tables

Signed-off-by: sonali wale <sonali.wale@progress.com>

* Insert scripts added for migration type and status

Signed-off-by: sonali wale <sonali.wale@progress.com>

* Server id column added in migration table

Signed-off-by: sonali wale <sonali.wale@progress.com>

* Index added on server_id column in migration table

Signed-off-by: sonali wale <sonali.wale@progress.com>
  • Loading branch information
sonali523 authored and vinay033 committed Mar 24, 2022
1 parent 2e82005 commit 5c173ff
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- drop table migration
DROP TABLE IF EXISTS migration;

-- drop table migration_type
DROP TABLE IF EXISTS migration_type;

-- drop table migration_status
DROP TABLE IF EXISTS migration_status;
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
--create table migration_type
CREATE TABLE IF NOT EXISTS migration_type (
id TEXT PRIMARY KEY,
type TEXT NOT NULL DEFAULT ''
);

--create table migration_status
CREATE TABLE IF NOT EXISTS migration_status (
id TEXT PRIMARY KEY,
status_message TEXT NOT NULL DEFAULT 'In Progress'
);

--create table migration
CREATE TABLE IF NOT EXISTS migration (
id TEXT PRIMARY KEY,
type_id TEXT NOT NULL references migration_type(id) ON DELETE RESTRICT,
status_id TEXT NOT NULL references migration_status(id) ON DELETE RESTRICT,
server_id TEXT NOT NULL references servers(id) ON DELETE RESTRICT,
total_succeeded int,
total_skipped int,
total_failed int,
created_at TIMESTAMPTZ NOT NULL,
updated_at TIMESTAMPTZ NOT NULL
);
CREATE INDEX IF NOT EXISTS migration_server_id_index ON migration (server_id);

-- Insert rows into migration_type
INSERT INTO migration_type (id,type)
VALUES (md5(RANDOM()::TEXT),'user'),
(md5(RANDOM()::TEXT),'org');

-- Insert rows into migration_status
INSERT INTO migration_status(id,status_message)
VALUES (md5(RANDOM()::TEXT),'In Progress'),
(md5(RANDOM()::TEXT),'Completed'),
(md5(RANDOM()::TEXT),'Failed');
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
- [`04_convert_table_to_human_readable_ids.up.sql`](04_convert_table_to_human_readable_ids.up.sql)
- [`05_remove_orgs_pkey.up.sql`](05_remove_orgs_pkey.up.sql)
- [`06_user_management.up.sql`](06_user_management.up.sql)
- [`07_migration.up.sql`](07_migration.up.sql)

0 comments on commit 5c173ff

Please sign in to comment.