-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Database script for migration tables (#6500)
* 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
Showing
3 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
components/infra-proxy-service/storage/postgres/migration/sql/07_migration.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
36 changes: 36 additions & 0 deletions
36
components/infra-proxy-service/storage/postgres/migration/sql/07_migration.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters