Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database script for migration tables #6500

Merged
merged 4 commits into from
Jan 5, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,34 @@
--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,
total_succeeded int,
total_skipped int,
total_failed int,
created_at TIMESTAMPTZ NOT NULL,
updated_at TIMESTAMPTZ NOT NULL
);

-- 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)