Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat(pg): add seed data (#609)
Danny Xu955fdb9c9e30
diff --git a/store/pg_seed/README.md b/store/pg_seed/README.mdnew file mode 100644index 0000000000..e69de29bb2diff --git a/store/pg_seed/release/10001__init_seed.sql b/store/pg_seed/release/10001__init_seed.sqlnew file mode 100644index 0000000000..e8007eeff4--- /dev/null+++ b/store/pg_seed/release/10001__init_seed.sql@@ -0,0 +1,539 @@+-- Create "test" and "prod" environments+INSERT INTO+ environment (+ id,+ creator_id,+ updater_id,+ name,+ "order"+ )+VALUES+ (+ 101,+ 1,+ 1,+ 'Test',+ 0+ );++INSERT INTO+ environment (+ id,+ creator_id,+ updater_id,+ name,+ "order"+ )+VALUES+ (+ 102,+ 1,+ 1,+ 'Prod',+ 1+ );++ALTER SEQUENCE environment_id_seq RESTART WITH 103;++INSERT INTO+ policy (+ creator_id,+ updater_id,+ environment_id,+ type,+ payload+ )+VALUES+ (+ 1,+ 1,+ 101,+ 'bb.policy.pipeline-approval',+ '{"value":"MANUAL_APPROVAL_NEVER"}'+ );++INSERT INTO+ policy (+ creator_id,+ updater_id,+ environment_id,+ type,+ payload+ )+VALUES+ (+ 1,+ 1,+ 102,+ 'bb.policy.pipeline-approval',+ '{"value":"MANUAL_APPROVAL_ALWAYS"}'+ );++INSERT INTO+ policy (+ creator_id,+ updater_id,+ environment_id,+ type,+ payload+ )+VALUES+ (+ 1,+ 1,+ 102,+ 'bb.policy.backup-plan',+ '{"schedule":"WEEKLY"}'+ );++-- Create label keys for `bb.location` and `bb.tenant`.+INSERT INTO+ label_key (+ id,+ creator_id,+ updater_id,+ key+ )+VALUES+ (+ 101,+ 1,+ 1,+ 'bb.location'+ );++INSERT INTO+ label_key (+ id,+ creator_id,+ updater_id,+ key+ )+VALUES+ (+ 102,+ 1,+ 1,+ 'bb.tenant'+ );++ALTER SEQUENCE label_key_id_seq RESTART WITH 103;++-- Create 1 "test", 1 "prod" instance (including * database and admin data source)+-- Both instances contains the connection info we expect user to setup according to https://docs.bytebase.com/install/docker#start-a-local-mysql-server-for-testing+-- Set host to 172.17.0.1 which is the default docker gateway ip.+-- Our quickstart guide suggests to run both Bytebase and MySQL using docker, and in such case, bytebase access the mysqld container via 172.17.0.1+-- "test" instance+INSERT INTO+ instance (+ id,+ creator_id,+ updater_id,+ environment_id,+ name,+ engine,+ engine_version,+ host,+ port,+ external_link+ )+VALUES+ (+ 101,+ 1,+ 1,+ 101,+ 'MySQL Test (Follow the "External Link" field to bring up the MySQL server)',+ 'MYSQL',+ '8.0.19',+ 'host.docker.internal',+ '3306',+ 'https://docs.bytebase.com/install/docker#start-a-local-mysql-server-for-testing'+ );++INSERT INTO+ instance (+ id,+ creator_id,+ updater_id,+ environment_id,+ name,+ engine,+ engine_version,+ host,+ port,+ external_link+ )+VALUES+ (+ 102,+ 1,+ 1,+ 102,+ 'MySQL Prod (Follow the "External Link" field to bring up the MySQL server)',+ 'MYSQL',+ '8.0.19',+ 'host.docker.internal',+ '3306',+ 'https://docs.bytebase.com/install/docker#start-a-local-mysql-server-for-testing'+ );++ALTER SEQUENCE instance_id_seq RESTART WITH 103;++INSERT INTO+ db (+ id,+ creator_id,+ updater_id,+ instance_id,+ project_id,+ name,+ character_set,+ "collation",+ sync_status,+ last_successful_sync_ts,+ schema_version+ )+VALUES+ (+ 101,+ 1,+ 1,+ 101,+ 1,+ '*',+ 'utf8mb4',+ 'utf8mb4_general_ci',+ 'OK',+ 0,+ ''+ );++INSERT INTO+ db (+ id,+ creator_id,+ updater_id,+ instance_id,+ project_id,+ name,+ character_set,+ "collation",+ sync_status,+ last_successful_sync_ts,+ schema_version+ )+VALUES+ (+ 102,+ 1,+ 1,+ 102,+ 1,+ '*',+ 'utf8mb4',+ 'utf8mb4_general_ci',+ 'OK',+ 0,+ ''+ );++ALTER SEQUENCE db_id_seq RESTART WITH 103;++INSERT INTO+ data_source (+ id,+ creator_id,+ updater_id,+ instance_id,+ database_id,+ name,+ TYPE,+ username,+ password+ )+VALUES+ (+ 101,+ 1,+ 1,+ 101,+ 101,+ 'Admin data source',+ 'ADMIN',+ 'root',+ 'testpwd1'+ );++INSERT INTO+ data_source (+ id,+ creator_id,+ updater_id,+ instance_id,+ database_id,+ name,+ TYPE,+ username,+ password+ )+VALUES+ (+ 102,+ 1,+ 1,+ 102,+ 102,+ 'Admin data source',+ 'ADMIN',+ 'root',+ 'testpwd1'+ );++ALTER SEQUENCE db_id_seq RESTART WITH 103;++-- Create pipeline/stage/task/issue for onboarding+-- Create pipeline 101 "Hello world"+INSERT INTO+ pipeline (+ id,+ creator_id,+ updater_id,+ name,+ status+ )+VALUES+ (+ 101,+ 1,+ 1,+ 'Pipeline - Hello world',+ 'OPEN'+ );++ALTER SEQUENCE pipeline_id_seq RESTART WITH 102;++-- Create stage 101, 102 for pipeline 101+INSERT INTO+ stage (+ id,+ creator_id,+ updater_id,+ pipeline_id,+ environment_id,+ name+ )+VALUES+ (+ 101,+ 1,+ 1,+ 101,+ 101,+ 'Test'+ );++INSERT INTO+ stage (+ id,+ creator_id,+ updater_id,+ pipeline_id,+ environment_id,+ name+ )+VALUES+ (+ 102,+ 1,+ 1,+ 101,+ 102,+ 'Prod'+ );++ALTER SEQUENCE pipeline_id_seq RESTART WITH 103;++-- Create task 101 for stage 101+INSERT INTO+ task (+ id,+ creator_id,+ updater_id,+ pipeline_id,+ stage_id,+ instance_id,+ database_id,+ name,+ type,+ status,+ payload+ )+VALUES+ (+ 101,+ 1,+ 1,+ 101,+ 101,+ 101,+ NULL,+ 'Welcome',+ 'bb.task.general',+ 'RUNNING',+ '{"statement":"SELECT ''Welcome Builders'';"}'+ );++-- Create task 102 for stage 102+INSERT INTO+ task (+ id,+ creator_id,+ updater_id,+ pipeline_id,+ stage_id,+ instance_id,+ database_id,+ name,+ type,+ status,+ payload+ )+VALUES+ (+ 102,+ 1,+ 1,+ 101,+ 102,+ 102,+ NULL,+ 'Let''s go',+ 'bb.task.general',+ 'PENDING_APPROVAL',+ '{"statement":"SELECT ''Let''s go'';"}'+ );++ALTER SEQUENCE task_id_seq RESTART WITH 103;++-- Create task_run for task 101+INSERT INTO+ task_run (+ creator_id,+ updater_id,+ task_id,+ name,+ status,+ type,+ comment,+ result,+ payload+ )+VALUES+ (+ 1,+ 1,+ 101,+ 'Welcome',+ 'FAILED',+ 'bb.task.general',+ '',+ '{"detail":"Something is not right..."}',+ ''+ );++INSERT INTO+ task_run (+ creator_id,+ updater_id,+ task_id,+ name,+ status,+ type,+ comment,+ payload+ )+VALUES+ (+ 1,+ 1,+ 101,+ 'Welcome',+ 'RUNNING',+ 'bb.task.general',+ 'Let''s give another try',+ ''+ );++-- Create issue 101 "Hello world"+INSERT INTO+ issue (+ id,+ creator_id,+ updater_id,+ project_id,+ pipeline_id,+ name,+ status,+ type,+ description,+ assignee_id+ )+VALUES+ (+ 101,+ 1,+ 1,+ 1,+ 101,+ 'Hello world!',+ 'OPEN',+ 'bb.issue.general',+ 'Welcome to Bytebase, this is the issue interface where developers and DBAs collaborate on database schema management issues such as: \n - Creating a new database\n - Creating a table\n - Creating an index\n - Adding/altering a column\n - Troubleshooting performance issue\nLet''s try some simple tasks:\n1. Bookmark this issue by clicking the star icon on the top of this page\n2. Leave a comment below to greet future comers\n3. Follow the Quickstart on the bottom left to get familiar with other features',+ 1+ );++ALTER SEQUENCE issue_id_seq RESTART WITH 102;++-- Create activity 101+INSERT INTO+ activity (+ id,+ creator_id,+ updater_id,+ container_id,+ type,+ level+ )+VALUES+ (+ 101,+ 1,+ 1,+ 101,+ 'bb.issue.create',+ 'INFO'+ );++INSERT INTO+ activity (+ id,+ creator_id,+ updater_id,+ container_id,+ type,+ level,+ comment+ )+VALUES+ (+ 102,+ 1,+ 1,+ 101,+ 'bb.issue.comment.create',+ 'INFO',+ 'Go fish!'+ );++ALTER SEQUENCE activity_id_seq RESTART WITH 103;diff --git a/store/pg_seed/release/README.md b/store/pg_seed/release/README.mdnew file mode 100644index 0000000000..f888101b79--- /dev/null+++ b/store/pg_seed/release/README.md@@ -0,0 +1,4 @@+This folder contains the seed data for release. The release seed data is used when building with "release" tag or running with --demo.++The seed data file name follows the same naming convention as the migration file like {{version_number}}\_\_{{description}}, where {{version_number}}+corresponds to the migration file having the same {{version_number}}. The particular release seed data file is ONLY loaded when the corresponding migration file has been applied, which means it should only be loaded once together with running the migration file.diff --git a/store/pg_seed/test/10000__reset.sql b/store/pg_seed/test/10000__reset.sqlnew file mode 100644index 0000000000..1eddbcc46f--- /dev/null+++ b/store/pg_seed/test/10000__reset.sql@@ -0,0 +1,117 @@+-- For testing, we reset data on each run+-- Do not reset bb.auth.secret so that we don't need to re-login after restart+DELETE FROM+ setting+WHERE+ name != 'bb.auth.secret';++DELETE FROM+ anomaly;++DELETE FROM+ repository;++DELETE FROM+ vcs;++DELETE FROM+ bookmark;++DELETE FROM+ inbox;++DELETE FROM+ activity;++DELETE FROM+ issue_subscriber;++DELETE FROM+ issue;++DELETE FROM+ task_check_run;++DELETE FROM+ task_run;++DELETE FROM+ task;++DELETE FROM+ stage;++DELETE FROM+ pipeline;++DELETE FROM+ data_source;++DELETE FROM+ vw;++DELETE FROM+ idx;++DELETE FROM+ col;++DELETE FROM+ tbl;++DELETE FROM+ backup;++DELETE FROM+ backup_setting;++-- Delete in this order following foreign constraints.+DELETE FROM+ db_label;++DELETE FROM+ label_value;++DELETE FROM+ label_key;++DELETE FROM+ db;++DELETE FROM+ instance_user;++DELETE FROM+ instance;++DELETE FROM+ policy;++DELETE FROM+ environment;++DELETE FROM+ project_webhook;++DELETE FROM+ project_member;++DELETE FROM+ deployment_config;++DELETE FROM+ sheet;+-- Project 1 refers to DEFAULT project which is considered as part of schema+DELETE FROM+ project+WHERE+ id != 1;++DELETE FROM+ member;++-- Principal 1 refers to bytebase system account which is considered as part of schema+DELETE FROM+ principal+WHERE+ id != 1;diff --git a/store/pg_seed/test/10001__principal.sql b/store/pg_seed/test/10001__principal.sqlnew file mode 100644index 0000000000..e15388e635--- /dev/null+++ b/store/pg_seed/test/10001__principal.sql@@ -0,0 +1,95 @@+-- End user id starts at 101, we reserve the range between 1 ~ 100 for internal use.+-- Setting the id explicitly changes the next id value to be +1+-- 101+INSERT INTO+ principal (+ id,+ creator_id,+ updater_id,+ type,+ name,+ email,+ password_hash+ )+VALUES+ (+ 101,+ 1,+ 1,+ 'END_USER',+ 'Demo Owner',+ '[email protected]',+ -- 1024+ '$2a$10$/65QFlHOmDzXshEMt/qYuunbJrXtRLcaYDcRODbyOPa/9/N0N8Zc2'+ );++-- 102+INSERT INTO+ principal (+ id,+ creator_id,+ updater_id,+ type,+ name,+ email,+ password_hash+ )+VALUES+ (+ 102,+ 1,+ 1,+ 'END_USER',+ 'Jerry DBA',+ '[email protected]',+ -- 2048+ '$2a$10$Q2NJib9bRvDkap1N1RDP2O3HyxjCldwfvGoxAzZL5gbbBgKAFD4cq'+ );++-- 103+INSERT INTO+ principal (+ id,+ creator_id,+ updater_id,+ type,+ name,+ email,+ password_hash+ )+VALUES+ (+ 103,+ 1,+ 1,+ 'END_USER',+ 'Tom Dev',+ '[email protected]',+ -- 4096+ '$2a$10$X5bvIWk4BKhEaZqlNLGjgOUB09i97olKBfjTQT49zMtNGnhoy6GIW'+ );++-- 104+INSERT INTO+ principal (+ id,+ creator_id,+ updater_id,+ type,+ name,+ email,+ password_hash+ )+VALUES+ (+ 104,+ 1,+ 1,+ 'END_USER',+ 'Jane Dev',+ '[email protected]',+ -- 8192+ '$2a$10$2QTgsuKDTGYe68lpeqRqouw1dQTRhssrYSnwQVzQUctQvhnVIccRa'+ );++ALTER SEQUENCE principal_id_seq RESTART WITH 105;diff --git a/store/pg_seed/test/10010__workspace.sql b/store/pg_seed/test/10010__workspace.sqlnew file mode 100644index 0000000000..026f1d2de6--- /dev/null+++ b/store/pg_seed/test/10010__workspace.sql@@ -0,0 +1 @@+-- 0010 is reserved for workspace, but is not implemented yet.diff --git a/store/pg_seed/test/10020__member.sql b/store/pg_seed/test/10020__member.sqlnew file mode 100644index 0000000000..53e43b2e59--- /dev/null+++ b/store/pg_seed/test/10020__member.sql@@ -0,0 +1,49 @@+INSERT INTO+ member (+ id,+ creator_id,+ updater_id,+ status,+ role,+ principal_id+ )+VALUES+ (2001, 101, 101, 'ACTIVE', 'OWNER', 101);++INSERT INTO+ member (+ id,+ creator_id,+ updater_id,+ status,+ role,+ principal_id+ )+VALUES+ (2002, 101, 101, 'ACTIVE', 'DBA', 102);++INSERT INTO+ member (+ id,+ creator_id,+ updater_id,+ status,+ role,+ principal_id+ )+VALUES+ (2003, 101, 101, 'ACTIVE', 'DEVELOPER', 103);++INSERT INTO+ member (+ id,+ creator_id,+ updater_id,+ status,+ role,+ principal_id+ )+VALUES+ (2004, 101, 101, 'ACTIVE', 'DEVELOPER', 104);++ALTER SEQUENCE member_id_seq RESTART WITH 2005;diff --git a/store/pg_seed/test/10030__project.sql b/store/pg_seed/test/10030__project.sqlnew file mode 100644index 0000000000..b4655d8d48--- /dev/null+++ b/store/pg_seed/test/10030__project.sql@@ -0,0 +1,178 @@+INSERT INTO+ project (+ id,+ creator_id,+ updater_id,+ name,+ key,+ workflow_type,+ visibility,+ tenant_mode,+ db_name_template+ )+VALUES+ (+ 3001,+ 101,+ 101,+ 'Test (UI)',+ 'TEST',+ 'UI',+ 'PUBLIC',+ 'DISABLED',+ ''+ );++INSERT INTO+ project (+ id,+ creator_id,+ updater_id,+ name,+ key,+ workflow_type,+ visibility,+ tenant_mode,+ db_name_template+ )+VALUES+ (+ 3002,+ 101,+ 101,+ 'Shop (Git)',+ 'SHP',+ 'VCS',+ 'PUBLIC',+ 'DISABLED',+ ''+ );++INSERT INTO+ project (+ id,+ creator_id,+ updater_id,+ name,+ key,+ workflow_type,+ visibility,+ tenant_mode,+ db_name_template+ )+VALUES+ (+ 3003,+ 101,+ 101,+ 'Blog (Git)',+ 'BLG',+ 'VCS',+ 'PUBLIC',+ 'DISABLED',+ ''+ );++INSERT INTO+ project (+ id,+ row_status,+ creator_id,+ updater_id,+ name,+ key,+ workflow_type,+ visibility,+ tenant_mode,+ db_name_template+ )+VALUES+ (+ 3004,+ 'ARCHIVED',+ 101,+ 101,+ 'Retired Project',+ 'RTR',+ 'UI',+ 'PUBLIC',+ 'DISABLED',+ ''+ );++INSERT INTO+ project (+ id,+ creator_id,+ updater_id,+ name,+ key,+ workflow_type,+ visibility,+ tenant_mode,+ db_name_template+ )+VALUES+ (+ 3005,+ 101,+ 101,+ 'Tenant (Git)',+ 'TNTG',+ 'VCS',+ 'PUBLIC',+ 'TENANT',+ ''+ );++INSERT INTO+ project (+ id,+ creator_id,+ updater_id,+ name,+ key,+ workflow_type,+ visibility,+ tenant_mode,+ db_name_template+ )+VALUES+ (+ 3006,+ 101,+ 101,+ 'Tenant (UI)',+ 'TNTU',+ 'UI',+ 'PUBLIC',+ 'TENANT',+ ''+ );++INSERT INTO+ project (+ id,+ creator_id,+ updater_id,+ name,+ key,+ workflow_type,+ visibility,+ tenant_mode,+ db_name_template+ )+VALUES+ (+ 3007,+ 101,+ 101,+ 'Tenant (db pattern)',+ 'TNMG',+ 'UI',+ 'PUBLIC',+ 'TENANT',+ '{{DB_NAME}}_{{TENANT}}'+ );++ALTER SEQUENCE project_id_seq RESTART WITH 3008;diff --git a/store/pg_seed/test/10040__project_member.sql b/store/pg_seed/test/10040__project_member.sqlnew file mode 100644index 0000000000..d982b84b77--- /dev/null+++ b/store/pg_seed/test/10040__project_member.sql@@ -0,0 +1,351 @@+-- Project 3001 membership+INSERT INTO+ project_member (+ id,+ creator_id,+ updater_id,+ project_id,+ role,+ principal_id+ )+VALUES+ (+ 4001,+ 101,+ 101,+ 3001,+ 'DEVELOPER',+ 101+ );++INSERT INTO+ project_member (+ id,+ creator_id,+ updater_id,+ project_id,+ role,+ principal_id+ )+VALUES+ (+ 4002,+ 101,+ 101,+ 3001,+ 'OWNER',+ 102+ );++INSERT INTO+ project_member (+ id,+ creator_id,+ updater_id,+ project_id,+ role,+ principal_id+ )+VALUES+ (+ 4003,+ 101,+ 101,+ 3001,+ 'DEVELOPER',+ 103+ );++-- Project 3002 membership+INSERT INTO+ project_member (+ id,+ creator_id,+ updater_id,+ project_id,+ role,+ principal_id+ )+VALUES+ (+ 4004,+ 101,+ 101,+ 3002,+ 'OWNER',+ 101+ );++INSERT INTO+ project_member (+ id,+ creator_id,+ updater_id,+ project_id,+ role,+ principal_id+ )+VALUES+ (+ 4005,+ 101,+ 101,+ 3002,+ 'DEVELOPER',+ 102+ );++-- Project 3003 membership+INSERT INTO+ project_member (+ id,+ creator_id,+ updater_id,+ project_id,+ role,+ principal_id+ )+VALUES+ (+ 4006,+ 101,+ 101,+ 3003,+ 'OWNER',+ 101+ );++INSERT INTO+ project_member (+ id,+ creator_id,+ updater_id,+ project_id,+ role,+ principal_id+ )+VALUES+ (+ 4007,+ 101,+ 101,+ 3003,+ 'DEVELOPER',+ 103+ );++-- Project 3004 membership+INSERT INTO+ project_member (+ id,+ creator_id,+ updater_id,+ project_id,+ role,+ principal_id+ )+VALUES+ (+ 4008,+ 101,+ 101,+ 3004,+ 'OWNER',+ 101+ );++INSERT INTO+ project_member (+ id,+ creator_id,+ updater_id,+ project_id,+ role,+ principal_id+ )+VALUES+ (+ 4009,+ 101,+ 101,+ 3004,+ 'OWNER',+ 102+ );++INSERT INTO+ project_member (+ id,+ creator_id,+ updater_id,+ project_id,+ role,+ principal_id+ )+VALUES+ (+ 4010,+ 101,+ 101,+ 3004,+ 'DEVELOPER',+ 103+ );++-- Project 3005 membership+INSERT INTO+ project_member (+ id,+ creator_id,+ updater_id,+ project_id,+ role,+ principal_id+ )+VALUES+ (+ 4011,+ 101,+ 101,+ 3005,+ 'OWNER',+ 101+ );++INSERT INTO+ project_member (+ id,+ creator_id,+ updater_id,+ project_id,+ role,+ principal_id+ )+VALUES+ (+ 4012,+ 101,+ 101,+ 3005,+ 'DEVELOPER',+ 102+ );++-- Project 3006 membership+INSERT INTO+ project_member (+ id,+ creator_id,+ updater_id,+ project_id,+ role,+ principal_id+ )+VALUES+ (+ 4013,+ 101,+ 101,+ 3006,+ 'OWNER',+ 101+ );++INSERT INTO+ project_member (+ id,+ creator_id,+ updater_id,+ project_id,+ role,+ principal_id+ )+VALUES+ (+ 4014,+ 101,+ 101,+ 3006,+ 'DEVELOPER',+ 102+ );++INSERT INTO+ project_member (+ id,+ creator_id,+ updater_id,+ project_id,+ role,+ principal_id+ )+VALUES+ (+ 4015,+ 101,+ 101,+ 3006,+ 'DEVELOPER',+ 103+ );+++-- Project 3007 membership+INSERT INTO+ project_member (+ id,+ creator_id,+ updater_id,+ project_id,+ role,+ principal_id+ )+VALUES+ (+ 4016,+ 101,+ 101,+ 3007,+ 'OWNER',+ 101+ );++INSERT INTO+ project_member (+ id,+ creator_id,+ updater_id,+ project_id,+ role,+ principal_id+ )+VALUES+ (+ 4017,+ 101,+ 101,+ 3007,+ 'DEVELOPER',+ 102+ );++INSERT INTO+ project_member (+ id,+ creator_id,+ updater_id,+ project_id,+ role,+ principal_id+ )+VALUES+ (+ 4018,+ 101,+ 101,+ 3007,+ 'DEVELOPER',+ 103+ );++ALTER SEQUENCE project_member_id_seq RESTART WITH 4019;diff --git a/store/pg_seed/test/10041__project_webhook.sql b/store/pg_seed/test/10041__project_webhook.sqlnew file mode 100644index 0000000000..f5fabeca90--- /dev/null+++ b/store/pg_seed/test/10041__project_webhook.sql@@ -0,0 +1,142 @@+-- Project 3001 hook+INSERT INTO+ project_webhook (+ id,+ creator_id,+ updater_id,+ project_id,+ type,+ name,+ url,+ activity_list+ )+VALUES+ (+ 4101,+ 101,+ 101,+ 3001,+ 'bb.plugin.webhook.wecom',+ 'WeCom',+ 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=12345',+ 'bb.issue.create,bb.issue.status.update,bb.pipeline.task.status.update,bb.issue.field.update,bb.issue.comment.create'+ );++INSERT INTO+ project_webhook (+ id,+ creator_id,+ updater_id,+ project_id,+ type,+ name,+ url,+ activity_list+ )+VALUES+ (+ 4102,+ 101,+ 101,+ 3001,+ 'bb.plugin.webhook.dingtalk',+ 'DingTalk',+ 'https://oapi.dingtalk.com/robot/send?access_token=12345',+ 'bb.issue.create,bb.issue.status.update,bb.pipeline.task.status.update,bb.issue.field.update,bb.issue.comment.create'+ );++-- Project 3002 hook+INSERT INTO+ project_webhook (+ id,+ creator_id,+ updater_id,+ project_id,+ type,+ name,+ url,+ activity_list+ )+VALUES+ (+ 4103,+ 101,+ 101,+ 3002,+ 'bb.plugin.webhook.feishu',+ 'Feishu',+ 'https://open.feishu.cn/open-apis/bot/v2/hook/12345',+ 'bb.issue.create,bb.issue.status.update,bb.pipeline.task.status.update,bb.issue.field.update,bb.issue.comment.create'+ );++INSERT INTO+ project_webhook (+ id,+ creator_id,+ updater_id,+ project_id,+ type,+ name,+ url,+ activity_list+ )+VALUES+ (+ 4104,+ 101,+ 101,+ 3002,+ 'bb.plugin.webhook.slack',+ 'Slack',+ 'https://hooks.slack.com/services/12345',+ 'bb.issue.create,bb.issue.status.update,bb.pipeline.task.status.update,bb.issue.field.update,bb.issue.comment.create'+ );++-- Project 3003 hook+INSERT INTO+ project_webhook (+ id,+ creator_id,+ updater_id,+ project_id,+ type,+ name,+ url,+ activity_list+ )+VALUES+ (+ 4105,+ 101,+ 101,+ 3003,+ 'bb.plugin.webhook.discord',+ 'Discord',+ 'https://discord.com/api/webhooks/12345',+ 'bb.issue.create,bb.issue.status.update,bb.pipeline.task.status.update,bb.issue.field.update,bb.issue.comment.create'+ );++INSERT INTO+ project_webhook (+ id,+ creator_id,+ updater_id,+ project_id,+ type,+ name,+ url,+ activity_list+ )+VALUES+ (+ 4106,+ 101,+ 101,+ 3003,+ 'bb.plugin.webhook.teams',+ 'Teams',+ 'https://foo.webhook.office.com/webhookb2/12345',+ 'bb.issue.create,bb.issue.status.update,bb.pipeline.task.status.update,bb.issue.field.update,bb.issue.comment.create'+ );++ALTER SEQUENCE project_webhook_id_seq RESTART WITH 4107;diff --git a/store/pg_seed/test/10050__environment.sql b/store/pg_seed/test/10050__environment.sqlnew file mode 100644index 0000000000..205d93b330--- /dev/null+++ b/store/pg_seed/test/10050__environment.sql@@ -0,0 +1,88 @@+INSERT INTO+ environment (+ id,+ creator_id,+ updater_id,+ name,+ "order"+ )+VALUES+ (+ 5001,+ 101,+ 101,+ 'Dev',+ 0+ );++INSERT INTO+ environment (+ id,+ creator_id,+ updater_id,+ name,+ "order"+ )+VALUES+ (+ 5002,+ 101,+ 101,+ 'Integration',+ 1+ );++INSERT INTO+ environment (+ id,+ creator_id,+ updater_id,+ name,+ "order"+ )+VALUES+ (+ 5003,+ 101,+ 101,+ 'Staging',+ 2+ );++INSERT INTO+ environment (+ id,+ creator_id,+ updater_id,+ name,+ "order"+ )+VALUES+ (+ 5004,+ 101,+ 101,+ 'Prod',+ 3+ );++INSERT INTO+ environment (+ id,+ row_status,+ creator_id,+ updater_id,+ name,+ "order"+ )+VALUES+ (+ 5005,+ 'ARCHIVED',+ 101,+ 101,+ 'Archived Env 1',+ 4+ );++ALTER SEQUENCE environment_id_seq RESTART WITH 5006;diff --git a/store/pg_seed/test/10051__policy.sql b/store/pg_seed/test/10051__policy.sqlnew file mode 100644index 0000000000..69ddc01aed--- /dev/null+++ b/store/pg_seed/test/10051__policy.sql@@ -0,0 +1,156 @@+INSERT INTO+ policy (+ id,+ creator_id,+ updater_id,+ environment_id,+ type,+ payload+ )+VALUES+ (+ 5101,+ 101,+ 101,+ 5001,+ 'bb.policy.pipeline-approval',+ '{"value":"MANUAL_APPROVAL_NEVER"}'+ );++INSERT INTO+ policy (+ id,+ creator_id,+ updater_id,+ environment_id,+ type,+ payload+ )+VALUES+ (+ 5102,+ 101,+ 101,+ 5002,+ 'bb.policy.pipeline-approval',+ '{"value":"MANUAL_APPROVAL_NEVER"}'+ );++INSERT INTO+ policy (+ id,+ creator_id,+ updater_id,+ environment_id,+ type,+ payload+ )+VALUES+ (+ 5103,+ 101,+ 101,+ 5003,+ 'bb.policy.pipeline-approval',+ '{"value":"MANUAL_APPROVAL_ALWAYS"}'+ );++INSERT INTO+ policy (+ id,+ creator_id,+ updater_id,+ environment_id,+ type,+ payload+ )+VALUES+ (+ 5104,+ 101,+ 101,+ 5004,+ 'bb.policy.pipeline-approval',+ '{"value":"MANUAL_APPROVAL_NEVER"}'+ );++INSERT INTO+ policy (+ id,+ creator_id,+ updater_id,+ environment_id,+ type,+ payload+ )+VALUES+ (+ 5105,+ 101,+ 101,+ 5005,+ 'bb.policy.pipeline-approval',+ '{"value":"MANUAL_APPROVAL_NEVER"}'+ );++INSERT INTO+ policy (+ id,+ creator_id,+ updater_id,+ environment_id,+ type,+ payload+ )+VALUES+ (+ 5106,+ 101,+ 101,+ 5003,+ 'bb.policy.backup-plan',+ '{"schedule":"WEEKLY"}'+ );++INSERT INTO+ policy (+ id,+ creator_id,+ updater_id,+ environment_id,+ type,+ payload+ )+VALUES+ (+ 5107,+ 101,+ 101,+ 5004,+ 'bb.policy.backup-plan',+ '{"schedule":"DAILY"}'+ );++-- Test upsert.+INSERT INTO+ policy (+ id,+ creator_id,+ updater_id,+ environment_id,+ type,+ payload+ )+VALUES+ (+ 5108,+ 101,+ 101,+ 5004,+ 'bb.policy.pipeline-approval',+ '{"value":"MANUAL_APPROVAL_ALWAYS"}'+ )+ ON CONFLICT(environment_id, type) DO UPDATE SET+ payload = excluded.payload;++ALTER SEQUENCE policy_id_seq RESTART WITH 5109;diff --git a/store/pg_seed/test/10060__instance.sql b/store/pg_seed/test/10060__instance.sqlnew file mode 100644index 0000000000..0471e6c9d3--- /dev/null+++ b/store/pg_seed/test/10060__instance.sql@@ -0,0 +1,246 @@+INSERT INTO+ instance (+ id,+ creator_id,+ updater_id,+ environment_id,+ name,+ engine,+ engine_version,+ host,+ port,+ external_link+ )+VALUES+ (+ 6001,+ 101,+ 101,+ 5001,+ 'Localhost Dev MySQL',+ 'MYSQL',+ '8.0.19',+ '127.0.0.1',+ '3306',+ 'bytebase.com/database/mysql'+ );++INSERT INTO+ instance (+ id,+ creator_id,+ updater_id,+ environment_id,+ name,+ engine,+ engine_version,+ host,+ port,+ external_link+ )+VALUES+ (+ 6002,+ 101,+ 101,+ 5002,+ 'On-premises Integration MySQL',+ 'MYSQL',+ '8.0.19',+ 'mysql.integration.example.com',+ '3306',+ 'bytebase.com/database/mysql'+ );++INSERT INTO+ instance (+ id,+ creator_id,+ updater_id,+ environment_id,+ name,+ engine,+ engine_version,+ host,+ port,+ external_link+ )+VALUES+ (+ 6003,+ 101,+ 101,+ 5003,+ 'On-premises Staging MySQL',+ 'MYSQL',+ '8.0.19',+ 'mysql.staging.example.com',+ '3306',+ 'bytebase.com/database/mysql'+ );++INSERT INTO+ instance (+ id,+ creator_id,+ updater_id,+ environment_id,+ name,+ engine,+ engine_version,+ host,+ port,+ external_link+ )+VALUES+ (+ 6004,+ 101,+ 101,+ 5004,+ 'On-premises Prod MySQL',+ 'MYSQL',+ '8.0.19',+ 'mysql.prod.example.com',+ '3306',+ 'bytebase.com/database/mysql'+ );++INSERT INTO+ instance (+ id,+ creator_id,+ updater_id,+ environment_id,+ name,+ engine,+ engine_version,+ host,+ port,+ external_link+ )+VALUES+ (+ 6005,+ 101,+ 101,+ 5001,+ 'Localhost Dev PostgreSQL',+ 'POSTGRES',+ '13.0',+ '127.0.0.1',+ '5432',+ 'bytebase.com/database/postgres'+ );++INSERT INTO+ instance (+ id,+ creator_id,+ updater_id,+ environment_id,+ name,+ engine,+ engine_version,+ host,+ port,+ external_link+ )+VALUES+ (+ 6006,+ 101,+ 101,+ 5001,+ 'Localhost Dev TiDB',+ 'TIDB',+ '5.7.25-TiDB-v5.2.1',+ '127.0.0.1',+ '4000',+ 'bytebase.com/database/tidb'+ );++INSERT INTO+ instance (+ id,+ creator_id,+ updater_id,+ environment_id,+ name,+ engine,+ engine_version,+ host,+ port,+ external_link+ )+VALUES+ (+ 6007,+ 101,+ 101,+ 5001,+ 'Localhost Dev ClickHouse',+ 'CLICKHOUSE',+ '21.10.2.15',+ '127.0.0.1',+ '9000',+ 'bytebase.com/database/clickhouse'+ );++INSERT INTO+ instance (+ id,+ creator_id,+ updater_id,+ environment_id,+ name,+ engine,+ engine_version,+ host,+ port,+ external_link+ )+VALUES+ (+ 6008,+ 101,+ 101,+ 5001,+ 'Localhost Dev Snowflake',+ 'SNOWFLAKE',+ '21.10.2.15',+ '127.0.0.1',+ '',+ 'bytebase.com/database/snowflake'+ );++INSERT INTO+ instance (+ id,+ row_status,+ creator_id,+ updater_id,+ environment_id,+ name,+ engine,+ engine_version,+ host,+ port,+ external_link+ )+VALUES+ (+ 6009,+ 'ARCHIVED',+ 101,+ 101,+ 5004,+ 'Retired Prod MySQL',+ 'MYSQL',+ '5.7.25',+ 'mysql.retired.example.com',+ '3306',+ 'bytebase.com/database/mysql'+ );++ALTER SEQUENCE instance_id_seq RESTART WITH 6010;diff --git a/store/pg_seed/test/10061__instance_user.sql b/store/pg_seed/test/10061__instance_user.sqlnew file mode 100644index 0000000000..23d071ceb8--- /dev/null+++ b/store/pg_seed/test/10061__instance_user.sql@@ -0,0 +1,96 @@+INSERT INTO+ instance_user (+ id,+ creator_id,+ updater_id,+ instance_id,+ name,+ "grant"+ )+VALUES+ (+ 6101,+ 1,+ 1,+ 6001,+ '`root`@`%`',+ 'GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, CREATE ROLE, DROP ROLE ON *.* TO `root`@`localhost` WITH GRANT OPTION'+ );++INSERT INTO+ instance_user (+ id,+ creator_id,+ updater_id,+ instance_id,+ name,+ "grant"+ )+VALUES+ (+ 6102,+ 1,+ 1,+ 6002,+ '`root`@`%`',+ 'GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, CREATE ROLE, DROP ROLE ON *.* TO `root`@`localhost` WITH GRANT OPTION'+ );++INSERT INTO+ instance_user (+ id,+ creator_id,+ updater_id,+ instance_id,+ name,+ "grant"+ )+VALUES+ (+ 6103,+ 1,+ 1,+ 6003,+ '`root`@`%`',+ 'GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, CREATE ROLE, DROP ROLE ON *.* TO `root`@`localhost` WITH GRANT OPTION'+ );++INSERT INTO+ instance_user (+ id,+ creator_id,+ updater_id,+ instance_id,+ name,+ "grant"+ )+VALUES+ (+ 6104,+ 1,+ 1,+ 6004,+ '`root`@`%`',+ 'GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, CREATE ROLE, DROP ROLE ON *.* TO `root`@`localhost` WITH GRANT OPTION'+ );++INSERT INTO+ instance_user (+ id,+ creator_id,+ updater_id,+ instance_id,+ name,+ "grant"+ )+VALUES+ (+ 6105,+ 1,+ 1,+ 6005,+ '`root`@`%`',+ 'GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, CREATE ROLE, DROP ROLE ON *.* TO `root`@`localhost` WITH GRANT OPTION'+ );++ALTER SEQUENCE instance_user_id_seq RESTART WITH 6106;diff --git a/store/pg_seed/test/10070__db.sql b/store/pg_seed/test/10070__db.sqlnew file mode 100644index 0000000000..aa0d76f024--- /dev/null+++ b/store/pg_seed/test/10070__db.sql@@ -0,0 +1,789 @@+-- Database for sandbox environment instance 6001+INSERT INTO+ db (+ id,+ creator_id,+ updater_id,+ instance_id,+ project_id,+ name,+ character_set,+ "collation",+ sync_status,+ last_successful_sync_ts,+ schema_version+ )+VALUES+ (+ 7001,+ 101,+ 101,+ 6001,+ 1,+ '*',+ 'utf8mb4',+ 'utf8mb4_general_ci',+ 'OK',+ 0,+ ''+ );++INSERT INTO+ db (+ id,+ creator_id,+ updater_id,+ instance_id,+ project_id,+ name,+ character_set,+ "collation",+ sync_status,+ last_successful_sync_ts,+ schema_version+ )+VALUES+ (+ 7002,+ 101,+ 101,+ 6001,+ 3001,+ 'testdb_dev',+ 'utf8mb4',+ 'utf8mb4_general_ci',+ 'OK',+ 1624558090,+ ''+ );++INSERT INTO+ db (+ id,+ creator_id,+ updater_id,+ instance_id,+ project_id,+ name,+ character_set,+ "collation",+ sync_status,+ last_successful_sync_ts,+ schema_version+ )+VALUES+ (+ 7003,+ 101,+ 101,+ 6001,+ 3002,+ 'shop',+ 'utf8mb4',+ 'utf8mb4_general_ci',+ 'OK',+ 0,+ ''+ );++INSERT INTO+ db (+ id,+ creator_id,+ updater_id,+ instance_id,+ project_id,+ name,+ character_set,+ "collation",+ sync_status,+ last_successful_sync_ts,+ schema_version+ )+VALUES+ (+ 7004,+ 101,+ 101,+ 6001,+ 3003,+ 'blog',+ 'utf8mb4',+ 'utf8mb4_general_ci',+ 'OK',+ 0,+ ''+ );++-- Database for integration environment instance 6002+INSERT INTO+ db (+ id,+ creator_id,+ updater_id,+ instance_id,+ project_id,+ name,+ character_set,+ "collation",+ sync_status,+ last_successful_sync_ts,+ schema_version+ )+VALUES+ (+ 7005,+ 101,+ 101,+ 6002,+ 1,+ '*',+ 'utf8mb4',+ 'utf8mb4_general_ci',+ 'OK',+ 0,+ ''+ );++INSERT INTO+ db (+ id,+ creator_id,+ updater_id,+ instance_id,+ project_id,+ name,+ character_set,+ "collation",+ sync_status,+ last_successful_sync_ts,+ schema_version+ )+VALUES+ (+ 7006,+ 101,+ 101,+ 6002,+ 3001,+ 'testdb_integration',+ 'utf8mb4',+ 'utf8mb4_general_ci',+ 'OK',+ 0,+ ''+ );++INSERT INTO+ db (+ id,+ creator_id,+ updater_id,+ instance_id,+ project_id,+ name,+ character_set,+ "collation",+ sync_status,+ last_successful_sync_ts,+ schema_version+ )+VALUES+ (+ 7007,+ 101,+ 101,+ 6002,+ 3002,+ 'shop',+ 'utf8mb4',+ 'utf8mb4_general_ci',+ 'OK',+ 0,+ ''+ );++INSERT INTO+ db (+ id,+ creator_id,+ updater_id,+ instance_id,+ project_id,+ name,+ character_set,+ "collation",+ sync_status,+ last_successful_sync_ts,+ schema_version+ )+VALUES+ (+ 7008,+ 101,+ 101,+ 6002,+ 3003,+ 'blog',+ 'utf8mb4',+ 'utf8mb4_general_ci',+ 'OK',+ 0,+ ''+ );++-- Database for staging environment instance 6003+INSERT INTO+ db (+ id,+ creator_id,+ updater_id,+ instance_id,+ project_id,+ name,+ character_set,+ "collation",+ sync_status,+ last_successful_sync_ts,+ schema_version+ )+VALUES+ (+ 7009,+ 101,+ 101,+ 6003,+ 1,+ '*',+ 'utf8mb4',+ 'utf8mb4_general_ci',+ 'OK',+ 0,+ ''+ );++INSERT INTO+ db (+ id,+ creator_id,+ updater_id,+ instance_id,+ project_id,+ name,+ character_set,+ "collation",+ sync_status,+ last_successful_sync_ts,+ schema_version+ )+VALUES+ (+ 7010,+ 101,+ 101,+ 6003,+ 3001,+ 'testdb_staging',+ 'utf8mb4',+ 'utf8mb4_general_ci',+ 'OK',+ 0,+ ''+ );++INSERT INTO+ db (+ id,+ creator_id,+ updater_id,+ instance_id,+ project_id,+ name,+ character_set,+ "collation",+ sync_status,+ last_successful_sync_ts,+ schema_version+ )+VALUES+ (+ 7011,+ 101,+ 101,+ 6003,+ 3002,+ 'shop',+ 'utf8mb4',+ 'utf8mb4_general_ci',+ 'OK',+ 0,+ ''+ );++INSERT INTO+ db (+ id,+ creator_id,+ updater_id,+ instance_id,+ project_id,+ name,+ character_set,+ "collation",+ sync_status,+ last_successful_sync_ts,+ schema_version+ )+VALUES+ (+ 7012,+ 101,+ 101,+ 6003,+ 3003,+ 'blog',+ 'utf8mb4',+ 'utf8mb4_general_ci',+ 'OK',+ 0,+ ''+ );++-- Database for prod environment instance 6004+INSERT INTO+ db (+ id,+ creator_id,+ updater_id,+ instance_id,+ project_id,+ name,+ character_set,+ "collation",+ sync_status,+ last_successful_sync_ts,+ schema_version+ )+VALUES+ (+ 7013,+ 101,+ 101,+ 6004,+ 1,+ '*',+ 'utf8mb4',+ 'utf8mb4_general_ci',+ 'OK',+ 0,+ ''+ );++INSERT INTO+ db (+ id,+ creator_id,+ updater_id,+ instance_id,+ project_id,+ name,+ character_set,+ "collation",+ sync_status,+ last_successful_sync_ts,+ schema_version+ )+VALUES+ (+ 7014,+ 101,+ 101,+ 6004,+ 3001,+ 'testdb_prod',+ 'utf8mb4',+ 'utf8mb4_general_ci',+ 'OK',+ 0,+ ''+ );++INSERT INTO+ db (+ id,+ creator_id,+ updater_id,+ instance_id,+ project_id,+ name,+ character_set,+ "collation",+ sync_status,+ last_successful_sync_ts,+ schema_version+ )+VALUES+ (+ 7015,+ 101,+ 101,+ 6004,+ 3002,+ 'shop',+ 'utf8mb4',+ 'utf8mb4_general_ci',+ 'OK',+ 0,+ ''+ );++INSERT INTO+ db (+ id,+ creator_id,+ updater_id,+ instance_id,+ project_id,+ name,+ character_set,+ "collation",+ sync_status,+ last_successful_sync_ts,+ schema_version+ )+VALUES+ (+ 7016,+ 101,+ 101,+ 6004,+ 3003,+ 'blog',+ 'utf8mb4',+ 'utf8mb4_general_ci',+ 'OK',+ 0,+ ''+ );++-- Database for dev environment PostgreSQL instance 6005+INSERT INTO+ db (+ id,+ creator_id,+ updater_id,+ instance_id,+ project_id,+ name,+ character_set,+ "collation",+ sync_status,+ last_successful_sync_ts,+ schema_version+ )+VALUES+ (+ 7017,+ 101,+ 101,+ 6005,+ 1,+ '*',+ 'utf8mb4',+ 'utf8mb4_general_ci',+ 'OK',+ 0,+ ''+ );++-- Database for dev environment TiDB instance 6006+INSERT INTO+ db (+ id,+ creator_id,+ updater_id,+ instance_id,+ project_id,+ name,+ character_set,+ "collation",+ sync_status,+ last_successful_sync_ts,+ schema_version+ )+VALUES+ (+ 7018,+ 101,+ 101,+ 6006,+ 1,+ '*',+ 'utf8mb4',+ 'utf8mb4_general_ci',+ 'OK',+ 0,+ ''+ );++-- Database for dev environment ClickHouse instance 6007+INSERT INTO+ db (+ id,+ creator_id,+ updater_id,+ instance_id,+ project_id,+ name,+ character_set,+ "collation",+ sync_status,+ last_successful_sync_ts,+ schema_version+ )+VALUES+ (+ 7019,+ 101,+ 101,+ 6007,+ 1,+ '*',+ 'utf8mb4',+ 'utf8mb4_general_ci',+ 'OK',+ 0,+ ''+ );++-- Database for dev environment Snowflake instance 6008+INSERT INTO+ db (+ id,+ creator_id,+ updater_id,+ instance_id,+ project_id,+ name,+ character_set,+ "collation",+ sync_status,+ last_successful_sync_ts,+ schema_version+ )+VALUES+ (+ 7020,+ 101,+ 101,+ 6008,+ 1,+ '*',+ '',+ '',+ 'OK',+ 0,+ ''+ );++-- Databases for tenant mode project.+INSERT INTO+ db (+ id,+ creator_id,+ updater_id,+ instance_id,+ project_id,+ name,+ character_set,+ "collation",+ sync_status,+ last_successful_sync_ts,+ schema_version+ )+VALUES+ (+ 7021,+ 101,+ 101,+ 6001,+ 3005,+ 'tenant_db1',+ 'utf8mb4',+ 'utf8mb4_general_ci',+ 'OK',+ 1624558090,+ 'v1'+ );+INSERT INTO+ db (+ id,+ creator_id,+ updater_id,+ instance_id,+ project_id,+ name,+ character_set,+ "collation",+ sync_status,+ last_successful_sync_ts,+ schema_version+ )+VALUES+ (+ 7022,+ 101,+ 101,+ 6002,+ 3005,+ 'tenant_db1',+ 'utf8mb4',+ 'utf8mb4_general_ci',+ 'OK',+ 1624558090,+ 'v1'+ );+INSERT INTO+ db (+ id,+ creator_id,+ updater_id,+ instance_id,+ project_id,+ name,+ character_set,+ "collation",+ sync_status,+ last_successful_sync_ts,+ schema_version+ )+VALUES+ (+ 7023,+ 101,+ 101,+ 6001,+ 3006,+ 'tenant_db2',+ 'utf8mb4',+ 'utf8mb4_general_ci',+ 'OK',+ 1624558090,+ '2021v1'+ );+INSERT INTO+ db (+ id,+ creator_id,+ updater_id,+ instance_id,+ project_id,+ name,+ character_set,+ "collation",+ sync_status,+ last_successful_sync_ts,+ schema_version+ )+VALUES+ (+ 7024,+ 101,+ 101,+ 6002,+ 3006,+ 'tenant_db2',+ 'utf8mb4',+ 'utf8mb4_general_ci',+ 'OK',+ 1624558090,+ '2021v1'+ );+INSERT INTO+ db (+ id,+ creator_id,+ updater_id,+ instance_id,+ project_id,+ name,+ character_set,+ "collation",+ sync_status,+ last_successful_sync_ts,+ schema_version+ )+VALUES+ (+ 7025,+ 101,+ 101,+ 6001,+ 3007,+ 'db3_tenant1',+ 'utf8mb4',+ 'utf8mb4_general_ci',+ 'OK',+ 1624558090,+ '2022v0'+ );+INSERT INTO+ db (+ id,+ creator_id,+ updater_id,+ instance_id,+ project_id,+ name,+ character_set,+ "collation",+ sync_status,+ last_successful_sync_ts,+ schema_version+ )+VALUES+ (+ 7026,+ 101,+ 101,+ 6002,+ 3007,+ 'db3_tenant2',+ 'utf8mb4',+ 'utf8mb4_general_ci',+ 'OK',+ 1624558090,+ '2022v0'+ );++-- Database for prod environment archived mysql instance 6009+INSERT INTO+ db (+ id,+ creator_id,+ updater_id,+ instance_id,+ project_id,+ name,+ character_set,+ "collation",+ sync_status,+ last_successful_sync_ts,+ schema_version+ )+VALUES+ (+ 7027,+ 101,+ 101,+ 6009,+ 3001,+ '*',+ 'utf8mb4',+ 'utf8mb4_general_ci',+ 'OK',+ 0,+ ''+ );++ALTER SEQUENCE db_id_seq RESTART WITH 7028;diff --git a/store/pg_seed/test/10071__tbl.sql b/store/pg_seed/test/10071__tbl.sqlnew file mode 100644index 0000000000..6597d5b112--- /dev/null+++ b/store/pg_seed/test/10071__tbl.sql@@ -0,0 +1,641 @@+-- Table for database 7002 testdb_dev+INSERT INTO+ tbl (+ id,+ creator_id,+ updater_id,+ database_id,+ name,+ type,+ ENGINE,+ "collation",+ row_count,+ data_size,+ index_size,+ data_free,+ create_options,+ comment+ )+VALUES+ (+ 7101,+ 101,+ 101,+ 7002,+ 'tbl1',+ 'BASE TABLE',+ 'InnoDB',+ 'utf8mb4_general_ci',+ 1234,+ 16384,+ 0,+ 0,+ '',+ ''+ );++-- Table for database 7006 testdb_integration+INSERT INTO+ tbl (+ id,+ creator_id,+ updater_id,+ database_id,+ name,+ type,+ ENGINE,+ "collation",+ row_count,+ data_size,+ index_size,+ data_free,+ create_options,+ comment+ )+VALUES+ (+ 7102,+ 101,+ 101,+ 7006,+ 'tbl1',+ 'BASE TABLE',+ 'InnoDB',+ 'utf8mb4_general_ci',+ 1234,+ 16384,+ 16384,+ 65536,+ '',+ ''+ );++-- Table for database 7010 testdb_staging+INSERT INTO+ tbl (+ id,+ creator_id,+ updater_id,+ database_id,+ name,+ type,+ ENGINE,+ "collation",+ row_count,+ data_size,+ index_size,+ data_free,+ create_options,+ comment+ )+VALUES+ (+ 7103,+ 101,+ 101,+ 7010,+ 'tbl1',+ 'BASE TABLE',+ 'InnoDB',+ 'utf8mb4_general_ci',+ 12234,+ 65536,+ 16384,+ 655360,+ '',+ ''+ );++-- Table for database 7014 testdb_prod+INSERT INTO+ tbl (+ id,+ creator_id,+ updater_id,+ database_id,+ name,+ type,+ ENGINE,+ "collation",+ row_count,+ data_size,+ index_size,+ data_free,+ create_options,+ comment+ )+VALUES+ (+ 7104,+ 101,+ 101,+ 7014,+ 'tbl1',+ 'BASE TABLE',+ 'InnoDB',+ 'utf8mb4_general_ci',+ 1234,+ 32768,+ 4096,+ 327680,+ '',+ ''+ );++-- Table for database 7003 shop+INSERT INTO+ tbl (+ id,+ creator_id,+ updater_id,+ database_id,+ name,+ type,+ ENGINE,+ "collation",+ row_count,+ data_size,+ index_size,+ data_free,+ create_options,+ comment+ )+VALUES+ (+ 7105,+ 101,+ 101,+ 7003,+ 'product',+ 'BASE TABLE',+ 'InnoDB',+ 'utf8mb4_general_ci',+ 1000,+ 4096,+ 0,+ 409600,+ '',+ ''+ );++-- Table for database 7007 shop+INSERT INTO+ tbl (+ id,+ creator_id,+ updater_id,+ database_id,+ name,+ type,+ ENGINE,+ "collation",+ row_count,+ data_size,+ index_size,+ data_free,+ create_options,+ comment+ )+VALUES+ (+ 7106,+ 101,+ 101,+ 7007,+ 'product',+ 'BASE TABLE',+ 'InnoDB',+ 'utf8mb4_general_ci',+ 1000,+ 4096,+ 1024,+ 0,+ '',+ ''+ );++-- Table for database 7004 blog+INSERT INTO+ tbl (+ id,+ creator_id,+ updater_id,+ database_id,+ name,+ type,+ ENGINE,+ "collation",+ row_count,+ data_size,+ index_size,+ data_free,+ create_options,+ comment+ )+VALUES+ (+ 7107,+ 101,+ 101,+ 7004,+ 'user',+ 'BASE TABLE',+ 'InnoDB',+ 'utf8mb4_general_ci',+ 1000,+ 4096,+ 1024,+ 204800,+ '',+ ''+ );++INSERT INTO+ tbl (+ id,+ creator_id,+ updater_id,+ database_id,+ name,+ type,+ ENGINE,+ "collation",+ row_count,+ data_size,+ index_size,+ data_free,+ create_options,+ comment+ )+VALUES+ (+ 7108,+ 101,+ 101,+ 7004,+ 'post',+ 'BASE TABLE',+ 'InnoDB',+ 'utf8mb4_general_ci',+ 1000,+ 8192,+ 1024,+ 204800,+ '',+ ''+ );++INSERT INTO+ tbl (+ id,+ creator_id,+ updater_id,+ database_id,+ name,+ type,+ ENGINE,+ "collation",+ row_count,+ data_size,+ index_size,+ data_free,+ create_options,+ comment+ )+VALUES+ (+ 7109,+ 101,+ 101,+ 7004,+ 'comment',+ 'BASE TABLE',+ 'InnoDB',+ 'utf8mb4_general_ci',+ 30000,+ 65536,+ 4096,+ 102400,+ '',+ ''+ );++-- Table for database 7008 blog+INSERT INTO+ tbl (+ id,+ creator_id,+ updater_id,+ database_id,+ name,+ type,+ ENGINE,+ "collation",+ row_count,+ data_size,+ index_size,+ data_free,+ create_options,+ comment+ )+VALUES+ (+ 7110,+ 101,+ 101,+ 7008,+ 'user',+ 'BASE TABLE',+ 'InnoDB',+ 'utf8mb4_general_ci',+ 100,+ 4096,+ 0,+ 204800,+ '',+ ''+ );++INSERT INTO+ tbl (+ id,+ creator_id,+ updater_id,+ database_id,+ name,+ type,+ ENGINE,+ "collation",+ row_count,+ data_size,+ index_size,+ data_free,+ create_options,+ comment+ )+VALUES+ (+ 7111,+ 101,+ 101,+ 7008,+ 'post',+ 'BASE TABLE',+ 'InnoDB',+ 'utf8mb4_general_ci',+ 300,+ 4096,+ 1024,+ 102400,+ '',+ ''+ );++INSERT INTO+ tbl (+ id,+ creator_id,+ updater_id,+ database_id,+ name,+ type,+ ENGINE,+ "collation",+ row_count,+ data_size,+ index_size,+ data_free,+ create_options,+ comment+ )+VALUES+ (+ 7112,+ 101,+ 101,+ 7008,+ 'comment',+ 'BASE TABLE',+ 'InnoDB',+ 'utf8mb4_general_ci',+ 2000,+ 65536,+ 2048,+ 40960,+ '',+ ''+ );++-- Table for database 7012 blog+INSERT INTO+ tbl (+ id,+ creator_id,+ updater_id,+ database_id,+ name,+ type,+ ENGINE,+ "collation",+ row_count,+ data_size,+ index_size,+ data_free,+ create_options,+ comment+ )+VALUES+ (+ 7113,+ 101,+ 101,+ 7012,+ 'user',+ 'BASE TABLE',+ 'InnoDB',+ 'utf8mb4_general_ci',+ 200,+ 4096,+ 1024,+ 81920,+ '',+ ''+ );++INSERT INTO+ tbl (+ id,+ creator_id,+ updater_id,+ database_id,+ name,+ type,+ ENGINE,+ "collation",+ row_count,+ data_size,+ index_size,+ data_free,+ create_options,+ comment+ )+VALUES+ (+ 7114,+ 101,+ 101,+ 7012,+ 'post',+ 'BASE TABLE',+ 'InnoDB',+ 'utf8mb4_general_ci',+ 500,+ 4096,+ 1024,+ 8192,+ '',+ ''+ );++INSERT INTO+ tbl (+ id,+ creator_id,+ updater_id,+ database_id,+ name,+ type,+ ENGINE,+ "collation",+ row_count,+ data_size,+ index_size,+ data_free,+ create_options,+ comment+ )+VALUES+ (+ 7115,+ 101,+ 101,+ 7012,+ 'comment',+ 'BASE TABLE',+ 'InnoDB',+ 'utf8mb4_general_ci',+ 4000,+ 65536,+ 65536,+ 20480,+ '',+ ''+ );++-- Table for database 7016 blog+INSERT INTO+ tbl (+ id,+ creator_id,+ updater_id,+ database_id,+ name,+ type,+ ENGINE,+ "collation",+ row_count,+ data_size,+ index_size,+ data_free,+ create_options,+ comment+ )+VALUES+ (+ 7116,+ 101,+ 101,+ 7016,+ 'user',+ 'BASE TABLE',+ 'InnoDB',+ 'utf8mb4_general_ci',+ 200,+ 4096,+ 1024,+ 0,+ '',+ ''+ );++INSERT INTO+ tbl (+ id,+ creator_id,+ updater_id,+ database_id,+ name,+ type,+ ENGINE,+ "collation",+ row_count,+ data_size,+ index_size,+ data_free,+ create_options,+ comment+ )+VALUES+ (+ 7117,+ 101,+ 101,+ 7016,+ 'post',+ 'BASE TABLE',+ 'InnoDB',+ 'utf8mb4_general_ci',+ 500,+ 4096,+ 1024,+ 2048,+ '',+ ''+ );++INSERT INTO+ tbl (+ id,+ creator_id,+ updater_id,+ database_id,+ name,+ type,+ ENGINE,+ "collation",+ row_count,+ data_size,+ index_size,+ data_free,+ create_options,+ comment+ )+VALUES+ (+ 7118,+ 101,+ 101,+ 7016,+ 'comment',+ 'BASE TABLE',+ 'InnoDB',+ 'utf8mb4_general_ci',+ 7000,+ 8192,+ 0,+ 8192,+ '',+ ''+ );++ALTER SEQUENCE tbl_id_seq RESTART WITH 7119;diff --git a/store/pg_seed/test/10072__col.sql b/store/pg_seed/test/10072__col.sqlnew file mode 100644index 0000000000..13cce5a218--- /dev/null+++ b/store/pg_seed/test/10072__col.sql@@ -0,0 +1,1801 @@+-- Column for database 7002 testdb_dev, table 7101 tbl1+INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7201,+ 101,+ 101,+ 7002,+ 7101,+ 'col1',+ 1,+ NULL,+ 0,+ 'text',+ 'utf8mb4',+ 'utf8mb4_0900_ai_ci',+ 'I am a comment'+ );++-- Column for database 7006 testdb_integration, table 7102 tbl1+INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7202,+ 101,+ 101,+ 7006,+ 7102,+ 'col1',+ 1,+ NULL,+ 0,+ 'text',+ 'utf8mb4',+ 'utf8mb4_0900_ai_ci',+ 'I am a comment'+ );++-- Column for database 7010 testdb_staging, table 7103 tbl1+INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7203,+ 101,+ 101,+ 7010,+ 7103,+ 'col1',+ 1,+ NULL,+ 0,+ 'text',+ 'utf8mb4',+ 'utf8mb4_0900_ai_ci',+ 'I am a comment'+ );++-- Column for database 7014 testdb_prod, table 7104 tbl1+INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7204,+ 101,+ 101,+ 7014,+ 7104,+ 'col1',+ 1,+ NULL,+ 0,+ 'text',+ 'utf8mb4',+ 'utf8mb4_0900_ai_ci',+ 'I am a comment'+ );++-- Column for database 7003 shop, table 7105 product+INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7205,+ 101,+ 101,+ 7003,+ 7105,+ 'id',+ 1,+ NULL,+ 0,+ 'int',+ '',+ '',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7206,+ 101,+ 101,+ 7003,+ 7105,+ 'name',+ 2,+ NULL,+ 0,+ 'text',+ 'utf8mb4',+ 'utf8mb4_0900_ai_ci',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7207,+ 101,+ 101,+ 7003,+ 7105,+ 'description',+ 3,+ NULL,+ 0,+ 'text',+ 'utf8mb4',+ 'utf8mb4_0900_ai_ci',+ ''+ );++-- Column for database 7007 shop, table 7106 product+INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7208,+ 101,+ 101,+ 7007,+ 7106,+ 'id',+ 1,+ NULL,+ 0,+ 'int',+ '',+ '',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7209,+ 101,+ 101,+ 7007,+ 7106,+ 'name',+ 2,+ NULL,+ 0,+ 'text',+ 'utf8mb4',+ 'utf8mb4_0900_ai_ci',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7210,+ 101,+ 101,+ 7007,+ 7106,+ 'description',+ 3,+ NULL,+ 0,+ 'text',+ 'utf8mb4',+ 'utf8mb4_0900_ai_ci',+ ''+ );++-- Column for database 7004 blog, table 7107 user+INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7211,+ 101,+ 101,+ 7004,+ 7107,+ 'id',+ 1,+ NULL,+ 0,+ 'int',+ '',+ '',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7212,+ 101,+ 101,+ 7004,+ 7107,+ 'name',+ 2,+ NULL,+ 0,+ 'text',+ 'utf8mb4',+ 'utf8mb4_0900_ai_ci',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7213,+ 101,+ 101,+ 7004,+ 7107,+ 'email',+ 3,+ NULL,+ 0,+ 'text',+ 'utf8mb4',+ 'utf8mb4_0900_ai_ci',+ ''+ );++-- Column for database 7004 blog, table 7108 post+INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7214,+ 101,+ 101,+ 7004,+ 7108,+ 'id',+ 1,+ NULL,+ 0,+ 'int',+ '',+ '',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7215,+ 101,+ 101,+ 7004,+ 7108,+ 'name',+ 2,+ NULL,+ 0,+ 'text',+ 'utf8mb4',+ 'utf8mb4_0900_ai_ci',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7216,+ 101,+ 101,+ 7004,+ 7108,+ 'content',+ 3,+ NULL,+ 0,+ 'text',+ 'utf8mb4',+ 'utf8mb4_0900_ai_ci',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7217,+ 101,+ 101,+ 7004,+ 7108,+ 'author_id',+ 4,+ NULL,+ 0,+ 'int',+ '',+ '',+ ''+ );++-- Column for database 7004 blog, table 7109 comment+INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7218,+ 101,+ 101,+ 7004,+ 7109,+ 'id',+ 1,+ NULL,+ 0,+ 'int',+ '',+ '',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7219,+ 101,+ 101,+ 7004,+ 7109,+ 'content',+ 2,+ NULL,+ 0,+ 'text',+ 'utf8mb4',+ 'utf8mb4_0900_ai_ci',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7220,+ 101,+ 101,+ 7004,+ 7109,+ 'post_id',+ 3,+ NULL,+ 0,+ 'int',+ '',+ '',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7221,+ 101,+ 101,+ 7004,+ 7109,+ 'author_id',+ 4,+ NULL,+ 0,+ 'int',+ '',+ '',+ ''+ );++-- Column for database 7008 blog, table 7110 user+INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7222,+ 101,+ 101,+ 7008,+ 7110,+ 'id',+ 1,+ NULL,+ 0,+ 'int',+ '',+ '',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7223,+ 101,+ 101,+ 7008,+ 7110,+ 'name',+ 2,+ NULL,+ 0,+ 'text',+ 'utf8mb4',+ 'utf8mb4_0900_ai_ci',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7224,+ 101,+ 101,+ 7008,+ 7110,+ 'email',+ 3,+ NULL,+ 0,+ 'text',+ 'utf8mb4',+ 'utf8mb4_0900_ai_ci',+ ''+ );++-- Column for database 7008 blog, table 7111 post+INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7225,+ 101,+ 101,+ 7008,+ 7111,+ 'id',+ 1,+ NULL,+ 0,+ 'int',+ '',+ '',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7226,+ 101,+ 101,+ 7008,+ 7111,+ 'name',+ 2,+ NULL,+ 0,+ 'text',+ 'utf8mb4',+ 'utf8mb4_0900_ai_ci',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7227,+ 101,+ 101,+ 7008,+ 7111,+ 'content',+ 3,+ NULL,+ 0,+ 'text',+ 'utf8mb4',+ 'utf8mb4_0900_ai_ci',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7228,+ 101,+ 101,+ 7008,+ 7111,+ 'author_id',+ 4,+ NULL,+ 0,+ 'int',+ '',+ '',+ ''+ );++-- Column for database 7008 blog, table 7112 comment+INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7229,+ 101,+ 101,+ 7008,+ 7112,+ 'id',+ 1,+ NULL,+ 0,+ 'int',+ '',+ '',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7230,+ 101,+ 101,+ 7008,+ 7112,+ 'content',+ 2,+ NULL,+ 0,+ 'text',+ 'utf8mb4',+ 'utf8mb4_0900_ai_ci',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7231,+ 101,+ 101,+ 7008,+ 7112,+ 'post_id',+ 3,+ NULL,+ 0,+ 'int',+ '',+ '',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7232,+ 101,+ 101,+ 7008,+ 7112,+ 'author_id',+ 4,+ NULL,+ 0,+ 'int',+ '',+ '',+ ''+ );++-- Column for database 7012 blog, table 7113 user+INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7233,+ 101,+ 101,+ 7012,+ 7113,+ 'id',+ 1,+ NULL,+ 0,+ 'int',+ '',+ '',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7234,+ 101,+ 101,+ 7012,+ 7113,+ 'name',+ 2,+ NULL,+ 0,+ 'text',+ 'utf8mb4',+ 'utf8mb4_0900_ai_ci',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7235,+ 101,+ 101,+ 7012,+ 7113,+ 'email',+ 3,+ NULL,+ 0,+ 'text',+ 'utf8mb4',+ 'utf8mb4_0900_ai_ci',+ ''+ );++-- Column for database 7012 blog, table 7114 post+INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7236,+ 101,+ 101,+ 7012,+ 7114,+ 'id',+ 1,+ NULL,+ 0,+ 'int',+ '',+ '',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7237,+ 101,+ 101,+ 7012,+ 7114,+ 'name',+ 2,+ NULL,+ 0,+ 'text',+ 'utf8mb4',+ 'utf8mb4_0900_ai_ci',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7238,+ 101,+ 101,+ 7012,+ 7114,+ 'content',+ 3,+ NULL,+ 0,+ 'text',+ 'utf8mb4',+ 'utf8mb4_0900_ai_ci',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7239,+ 101,+ 101,+ 7012,+ 7114,+ 'author_id',+ 4,+ NULL,+ 0,+ 'int',+ '',+ '',+ ''+ );++-- Column for database 7012 blog, table 7115 comment+INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7240,+ 101,+ 101,+ 7012,+ 7115,+ 'id',+ 1,+ NULL,+ 0,+ 'int',+ '',+ '',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7241,+ 101,+ 101,+ 7012,+ 7115,+ 'content',+ 2,+ NULL,+ 0,+ 'text',+ 'utf8mb4',+ 'utf8mb4_0900_ai_ci',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7242,+ 101,+ 101,+ 7012,+ 7115,+ 'post_id',+ 3,+ NULL,+ 0,+ 'int',+ '',+ '',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7243,+ 101,+ 101,+ 7012,+ 7115,+ 'author_id',+ 4,+ NULL,+ 0,+ 'int',+ '',+ '',+ ''+ );++-- Column for database 7016 blog, table 7116 user+INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7244,+ 101,+ 101,+ 7016,+ 7116,+ 'id',+ 1,+ NULL,+ 0,+ 'int',+ '',+ '',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7245,+ 101,+ 101,+ 7016,+ 7116,+ 'name',+ 2,+ NULL,+ 0,+ 'text',+ 'utf8mb4',+ 'utf8mb4_0900_ai_ci',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7246,+ 101,+ 101,+ 7016,+ 7116,+ 'email',+ 3,+ NULL,+ 0,+ 'text',+ 'utf8mb4',+ 'utf8mb4_0900_ai_ci',+ ''+ );++-- Column for database 7008 blog, table 7117 post+INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7247,+ 101,+ 101,+ 7016,+ 7117,+ 'id',+ 1,+ NULL,+ 0,+ 'int',+ '',+ '',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7248,+ 101,+ 101,+ 7016,+ 7117,+ 'name',+ 2,+ NULL,+ 0,+ 'text',+ 'utf8mb4',+ 'utf8mb4_0900_ai_ci',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7249,+ 101,+ 101,+ 7016,+ 7117,+ 'content',+ 3,+ NULL,+ 0,+ 'text',+ 'utf8mb4',+ 'utf8mb4_0900_ai_ci',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7250,+ 101,+ 101,+ 7016,+ 7117,+ 'author_id',+ 4,+ NULL,+ 0,+ 'int',+ '',+ '',+ ''+ );++-- Column for database 7016 blog, table 7118 comment+INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7251,+ 101,+ 101,+ 7016,+ 7118,+ 'id',+ 1,+ NULL,+ 0,+ 'int',+ '',+ '',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7252,+ 101,+ 101,+ 7016,+ 7118,+ 'content',+ 2,+ NULL,+ 0,+ 'text',+ 'utf8mb4',+ 'utf8mb4_0900_ai_ci',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7253,+ 101,+ 101,+ 7016,+ 7118,+ 'post_id',+ 3,+ NULL,+ 0,+ 'int',+ '',+ '',+ ''+ );++INSERT INTO+ col (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ position,+ "default",+ nullable,+ type,+ character_set,+ "collation",+ comment+ )+VALUES+ (+ 7254,+ 101,+ 101,+ 7016,+ 7118,+ 'author_id',+ 4,+ NULL,+ 0,+ 'int',+ '',+ '',+ ''+ );++ALTER SEQUENCE col_id_seq RESTART WITH 7255;diff --git a/store/pg_seed/test/10073__idx.sql b/store/pg_seed/test/10073__idx.sqlnew file mode 100644index 0000000000..eb53fa24f5--- /dev/null+++ b/store/pg_seed/test/10073__idx.sql@@ -0,0 +1,577 @@+-- Index for database 7002 testdb_dev, table 7101 tbl1+INSERT INTO+ idx (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ expression,+ position,+ type,+ "unique",+ visible,+ comment+ )+VALUES+ (+ 7301,+ 101,+ 101,+ 7002,+ 7101,+ 'idx_col1',+ 'col1',+ 1,+ 'BTREE',+ 0,+ 1,+ ''+ );++-- Index for database 7006 testdb_dev, table 7102 tbl1+INSERT INTO+ idx (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ expression,+ position,+ type,+ "unique",+ visible,+ comment+ )+VALUES+ (+ 7302,+ 101,+ 101,+ 7006,+ 7102,+ 'idx_col1',+ 'col1',+ 1,+ 'BTREE',+ 0,+ 1,+ ''+ );++-- Index for database 7010 testdb_dev, table 7103 tbl1+INSERT INTO+ idx (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ expression,+ position,+ type,+ "unique",+ visible,+ comment+ )+VALUES+ (+ 7303,+ 101,+ 101,+ 7010,+ 7103,+ 'idx_col1',+ 'col1',+ 1,+ 'BTREE',+ 1,+ 1,+ ''+ );++-- Index for database 7014 testdb_dev, table 7104 tbl1+INSERT INTO+ idx (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ expression,+ position,+ type,+ "unique",+ visible,+ comment+ )+VALUES+ (+ 7304,+ 101,+ 101,+ 7014,+ 7104,+ 'idx_col1',+ 'col1',+ 1,+ 'BTREE',+ 1,+ 1,+ ''+ );++-- Index for database 7003 shop, table 7105 product+INSERT INTO+ idx (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ expression,+ position,+ type,+ "unique",+ visible,+ comment+ )+VALUES+ (+ 7305,+ 101,+ 101,+ 7003,+ 7105,+ 'PRIMARY',+ 'id',+ 1,+ 'BTREE',+ 1,+ 1,+ ''+ );++-- Index for database 7007 shop, table 7106 product+INSERT INTO+ idx (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ expression,+ position,+ type,+ "unique",+ visible,+ comment+ )+VALUES+ (+ 7306,+ 101,+ 101,+ 7007,+ 7106,+ 'PRIMARY',+ 'id',+ 1,+ 'BTREE',+ 1,+ 1,+ ''+ );++-- Index for database 7004 blog, table 7107 user+INSERT INTO+ idx (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ expression,+ position,+ type,+ "unique",+ visible,+ comment+ )+VALUES+ (+ 7307,+ 101,+ 101,+ 7004,+ 7107,+ 'PRIMARY',+ 'id',+ 1,+ 'BTREE',+ 1,+ 1,+ ''+ );++-- Index for database 7004 blog, table 7108 post+INSERT INTO+ idx (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ expression,+ position,+ type,+ "unique",+ visible,+ comment+ )+VALUES+ (+ 7308,+ 101,+ 101,+ 7004,+ 7108,+ 'PRIMARY',+ 'id',+ 1,+ 'BTREE',+ 1,+ 1,+ ''+ );++-- Index for database 7004 blog, table 7109 comment+INSERT INTO+ idx (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ expression,+ position,+ type,+ "unique",+ visible,+ comment+ )+VALUES+ (+ 7309,+ 101,+ 101,+ 7004,+ 7109,+ 'PRIMARY',+ 'id',+ 1,+ 'BTREE',+ 1,+ 1,+ ''+ );++-- Index for database 7008 blog, table 7110 user+INSERT INTO+ idx (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ expression,+ position,+ type,+ "unique",+ visible,+ comment+ )+VALUES+ (+ 7310,+ 101,+ 101,+ 7008,+ 7110,+ 'PRIMARY',+ 'id',+ 1,+ 'BTREE',+ 1,+ 1,+ ''+ );++-- Index for database 7008 blog, table 7111 post+INSERT INTO+ idx (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ expression,+ position,+ type,+ "unique",+ visible,+ comment+ )+VALUES+ (+ 7311,+ 101,+ 101,+ 7008,+ 7111,+ 'PRIMARY',+ 'id',+ 1,+ 'BTREE',+ 1,+ 1,+ ''+ );++-- Index for database 7008 blog, table 7112 comment+INSERT INTO+ idx (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ expression,+ position,+ type,+ "unique",+ visible,+ comment+ )+VALUES+ (+ 7312,+ 101,+ 101,+ 7008,+ 7112,+ 'PRIMARY',+ 'id',+ 1,+ 'BTREE',+ 1,+ 1,+ ''+ );++-- Index for database 7012 blog, table 7113 user+INSERT INTO+ idx (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ expression,+ position,+ type,+ "unique",+ visible,+ comment+ )+VALUES+ (+ 7313,+ 101,+ 101,+ 7012,+ 7113,+ 'PRIMARY',+ 'id',+ 1,+ 'BTREE',+ 1,+ 1,+ ''+ );++-- Index for database 7012 blog, table 7114 post+INSERT INTO+ idx (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ expression,+ position,+ type,+ "unique",+ visible,+ comment+ )+VALUES+ (+ 7314,+ 101,+ 101,+ 7012,+ 7114,+ 'PRIMARY',+ 'id',+ 1,+ 'BTREE',+ 1,+ 1,+ ''+ );++-- Index for database 7012 blog, table 7115 comment+INSERT INTO+ idx (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ expression,+ position,+ type,+ "unique",+ visible,+ comment+ )+VALUES+ (+ 7315,+ 101,+ 101,+ 7012,+ 7115,+ 'PRIMARY',+ 'id',+ 1,+ 'BTREE',+ 1,+ 1,+ ''+ );++-- Index for database 7016 blog, table 7116 user+INSERT INTO+ idx (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ expression,+ position,+ type,+ "unique",+ visible,+ comment+ )+VALUES+ (+ 7316,+ 101,+ 101,+ 7016,+ 7116,+ 'PRIMARY',+ 'id',+ 1,+ 'BTREE',+ 1,+ 1,+ ''+ );++-- Index for database 7016 blog, table 7117 post+INSERT INTO+ idx (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ expression,+ position,+ type,+ "unique",+ visible,+ comment+ )+VALUES+ (+ 7317,+ 101,+ 101,+ 7016,+ 7117,+ 'PRIMARY',+ 'id',+ 1,+ 'BTREE',+ 1,+ 1,+ ''+ );++-- Index for database 7016 blog, table 7118 comment+INSERT INTO+ idx (+ id,+ creator_id,+ updater_id,+ database_id,+ table_id,+ name,+ expression,+ position,+ type,+ "unique",+ visible,+ comment+ )+VALUES+ (+ 7318,+ 101,+ 101,+ 7016,+ 7118,+ 'PRIMARY',+ 'id',+ 1,+ 'BTREE',+ 1,+ 1,+ ''+ );++ALTER SEQUENCE idx_id_seq RESTART WITH 7319;diff --git a/store/pg_seed/test/10074__backup.sql b/store/pg_seed/test/10074__backup.sqlnew file mode 100644index 0000000000..169dccf5e3--- /dev/null+++ b/store/pg_seed/test/10074__backup.sql@@ -0,0 +1,267 @@+-- Backup for database 7015 (shop database in prod environment)+INSERT INTO+ backup (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ database_id,+ name,+ status,+ type,+ storage_backend,+ migration_history_version,+ path,+ comment+ )+VALUES+ (+ 7401,+ 101,+ 1629136800,+ 101,+ 1629136800,+ 7015,+ 'shop-prod-20210817T094000',+ 'DONE',+ 'MANUAL',+ 'LOCAL',+ 'v1_20210817094000',+ 'data/backup/db/7015/shop-prod-20210817T094000.sql',+ ''+ );++INSERT INTO+ backup (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ database_id,+ name,+ status,+ type,+ storage_backend,+ migration_history_version,+ path,+ comment+ )+VALUES+ (+ 7402,+ 101,+ 1629250800,+ 101,+ 1629250800,+ 7015,+ 'shop-prod-20210818T140000',+ 'DONE',+ 'MANUAL',+ 'LOCAL',+ 'v2_20210818140000',+ 'data/backup/db/7015/shop-prod-20210818T140000.sql',+ ''+ );++INSERT INTO+ backup (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ database_id,+ name,+ status,+ type,+ storage_backend,+ migration_history_version,+ path,+ comment+ )+VALUES+ (+ 7403,+ 101,+ 1627754400,+ 101,+ 1627754400,+ 7015,+ 'shop-prod-20210801T020000-autobackup',+ 'FAILED',+ 'AUTOMATIC',+ 'LOCAL',+ 'v3_20210801020000',+ 'data/backup/db/7015/shop-prod-20210801T020000-autobackup.sql',+ 'Something unfortunate happened. Here is a long long long long long long long long long long long long long long long long long long long long long long long long error message.'+ );++INSERT INTO+ backup (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ database_id,+ name,+ status,+ type,+ storage_backend,+ migration_history_version,+ path,+ comment+ )+VALUES+ (+ 7405,+ 101,+ 1628359200,+ 101,+ 1628359200,+ 7015,+ 'shop-prod-20210808T020000-autobackup',+ 'DONE',+ 'AUTOMATIC',+ 'LOCAL',+ 'v3_20210808020000',+ 'data/backup/db/7015/shop-prod-20210808T020000-autobackup.sql',+ ''+ );++-- Backup for database 7016 (blog database in prod environment)+INSERT INTO+ backup (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ database_id,+ name,+ status,+ type,+ storage_backend,+ migration_history_version,+ path,+ comment+ )+VALUES+ (+ 7406,+ 101,+ 1629250800,+ 101,+ 1629250800,+ 7016,+ 'blog-prod-20210818T094000',+ 'DONE',+ 'MANUAL',+ 'LOCAL',+ 'v1_20210818094000',+ 'data/backup/db/7016/blog-prod-20210818T094000.sql',+ ''+ );++INSERT INTO+ backup (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ database_id,+ name,+ status,+ type,+ storage_backend,+ migration_history_version,+ path,+ comment+ )+VALUES+ (+ 7407,+ 101,+ 1629337200,+ 101,+ 1629337200,+ 7016,+ 'blog-prod-20210819T140000',+ 'DONE',+ 'MANUAL',+ 'LOCAL',+ 'v2_20210819140000',+ 'data/backup/db/7016/blog-prod-20210819T140000.sql',+ ''+ );++INSERT INTO+ backup (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ database_id,+ name,+ status,+ type,+ storage_backend,+ migration_history_version,+ path,+ comment+ )+VALUES+ (+ 7408,+ 101,+ 1627754400,+ 101,+ 1627754400,+ 7016,+ 'blog-prod-20210801T020000-autobackup',+ 'FAILED',+ 'AUTOMATIC',+ 'LOCAL',+ 'v3_20210801020000',+ 'data/backup/db/7016/blog-prod-20210801T020000-autobackup.sql',+ 'Something unfortunate happened. Here is a long long long long long long long long long long long long long long long long long long long long long long long long error message.'+ );++INSERT INTO+ backup (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ database_id,+ name,+ status,+ type,+ storage_backend,+ migration_history_version,+ path,+ comment+ )+VALUES+ (+ 7409,+ 101,+ 1628359200,+ 101,+ 1628359200,+ 7016,+ 'blog-prod-20210808T020000-autobackup',+ 'DONE',+ 'AUTOMATIC',+ 'LOCAL',+ 'v3_20210808020000',+ 'data/backup/db/7016/blog-prod-20210808T020000-autobackup.sql',+ ''+ );++ALTER SEQUENCE backup_id_seq RESTART WITH 7410;diff --git a/store/pg_seed/test/10080__data_source.sql b/store/pg_seed/test/10080__data_source.sqlnew file mode 100644index 0000000000..d0c52f0426--- /dev/null+++ b/store/pg_seed/test/10080__data_source.sql@@ -0,0 +1,226 @@+INSERT INTO+ data_source (+ id,+ creator_id,+ updater_id,+ instance_id,+ database_id,+ name,+ TYPE,+ username,+ PASSWORD+ )+VALUES+ (+ 8001,+ 1,+ 1,+ 6001,+ 7001,+ 'Admin data source',+ 'ADMIN',+ 'root',+ 'testpwd1'+ );++INSERT INTO+ data_source (+ id,+ creator_id,+ updater_id,+ instance_id,+ database_id,+ name,+ TYPE,+ username,+ PASSWORD+ )+VALUES+ (+ 8002,+ 1,+ 1,+ 6002,+ 7005,+ 'Admin data source',+ 'ADMIN',+ 'admin',+ 'Integration12345'+ );++INSERT INTO+ data_source (+ id,+ creator_id,+ updater_id,+ instance_id,+ database_id,+ name,+ TYPE,+ username,+ PASSWORD+ )+VALUES+ (+ 8003,+ 1,+ 1,+ 6003,+ 7009,+ 'Admin data source',+ 'ADMIN',+ 'admin',+ 'Staging12345'+ );++INSERT INTO+ data_source (+ id,+ creator_id,+ updater_id,+ instance_id,+ database_id,+ name,+ TYPE,+ username,+ PASSWORD+ )+VALUES+ (+ 8004,+ 1,+ 1,+ 6004,+ 7013,+ 'Admin data source',+ 'ADMIN',+ 'root',+ 'testpwd1'+ );++INSERT INTO+ data_source (+ id,+ creator_id,+ updater_id,+ instance_id,+ database_id,+ name,+ TYPE,+ username,+ PASSWORD+ )+VALUES+ (+ 8005,+ 1,+ 1,+ 6005,+ 7017,+ 'Admin data source',+ 'ADMIN',+ 'postgres',+ ''+ );++INSERT INTO+ data_source (+ id,+ creator_id,+ updater_id,+ instance_id,+ database_id,+ name,+ TYPE,+ username,+ PASSWORD+ )+VALUES+ (+ 8006,+ 1,+ 1,+ 6006,+ 7018,+ 'Admin data source',+ 'ADMIN',+ 'root',+ ''+ );++INSERT INTO+ data_source (+ id,+ creator_id,+ updater_id,+ instance_id,+ database_id,+ name,+ TYPE,+ username,+ PASSWORD+ )+VALUES+ (+ 8007,+ 1,+ 1,+ 6007,+ 7019,+ 'Admin data source',+ 'ADMIN',+ '',+ ''+ );++INSERT INTO+ data_source (+ id,+ creator_id,+ updater_id,+ instance_id,+ database_id,+ name,+ TYPE,+ username,+ PASSWORD+ )+VALUES+ (+ 8008,+ 1,+ 1,+ 6008,+ 7020,+ 'Admin data source',+ 'ADMIN',+ '',+ ''+ );++INSERT INTO+ data_source (+ id,+ creator_id,+ updater_id,+ instance_id,+ database_id,+ name,+ TYPE,+ username,+ PASSWORD+ )+VALUES+ (+ 8009,+ 1,+ 1,+ 6009,+ 7027,+ 'Admin data source',+ 'ADMIN',+ 'admin',+ 'Prod12345'+ );++ALTER SEQUENCE data_source_id_seq RESTART WITH 8010;diff --git a/store/pg_seed/test/10090__pipeline.sql b/store/pg_seed/test/10090__pipeline.sqlnew file mode 100644index 0000000000..1cab63b163--- /dev/null+++ b/store/pg_seed/test/10090__pipeline.sql@@ -0,0 +1,191 @@+-- A single stage, single task "hello world"+INSERT INTO+ pipeline (+ id,+ creator_id,+ updater_id,+ name,+ status+ )+VALUES+ (+ 9001,+ 101,+ 101,+ 'Pipeline - Hello world',+ 'OPEN'+ );++-- A multiple stage Pipeline for simulating webhook push event to create table for shop project database.+INSERT INTO+ pipeline (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ name,+ status+ )+VALUES+ (+ 9002,+ 1,+ 1624873710,+ 1,+ 1624873710,+ 'Pipeline - Create product table',+ 'OPEN'+ );++-- A two stage, each containing a single create table task, the 1st task has a failed task run+INSERT INTO+ pipeline (+ id,+ creator_id,+ updater_id,+ name,+ status+ )+VALUES+ (+ 9003,+ 103,+ 103,+ 'Pipeline - Create table ''tbl1''',+ 'CANCELED'+ );++-- Pipeline for simulating webhook push event to create table for blog project dev database.+INSERT INTO+ pipeline (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ name,+ status+ )+VALUES+ (+ 9004,+ 1,+ 1624865387,+ 1,+ 1624865387,+ 'Pipeline - Create user, post, comment table for dev environment',+ 'DONE'+ );++-- Pipeline for simulating webhook push event to create table for blog project integration database.+INSERT INTO+ pipeline (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ name,+ status+ )+VALUES+ (+ 9005,+ 1,+ 1624866790,+ 1,+ 1624866790,+ 'Pipeline - Create user, post, comment table for integration environment',+ 'DONE'+ );++-- Pipeline for simulating webhook push event to create table for blog project staging database.+INSERT INTO+ pipeline (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ name,+ status+ )+VALUES+ (+ 9006,+ 1,+ 1624868407,+ 1,+ 1624868407,+ 'Pipeline - Create user, post, comment table for staging environment',+ 'DONE'+ );++-- Pipeline for simulating webhook push event to create table for blog project prod database.+INSERT INTO+ pipeline (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ name,+ status+ )+VALUES+ (+ 9007,+ 1,+ 1624868680,+ 1,+ 1624868680,+ 'Pipeline - Create user, post, comment table for prod environment',+ 'DONE'+ );++-- Pipeline for simulating webhook push event to alter table for blog project dev database.+INSERT INTO+ pipeline (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ name,+ status+ )+VALUES+ (+ 9008,+ 1,+ 1624869944,+ 1,+ 1624869944,+ 'Pipeline - Add created_at column to user,post,comment table for dev environment',+ 'OPEN'+ );++-- Pipeline for multi-stage create table UI workflow+INSERT INTO+ pipeline (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ name,+ status+ )+VALUES+ (+ 9009,+ 103,+ 1624879944,+ 103,+ 1624879944,+ 'Pipeline - Create a new table tbl2',+ 'OPEN'+ );++ALTER SEQUENCE pipeline_id_seq RESTART WITH 9010;diff --git a/store/pg_seed/test/10100__stage.sql b/store/pg_seed/test/10100__stage.sqlnew file mode 100644index 0000000000..7cb971f27a--- /dev/null+++ b/store/pg_seed/test/10100__stage.sql@@ -0,0 +1,366 @@+-- Stage for Pipeline 9001 "Hello world"+INSERT INTO+ stage (+ id,+ creator_id,+ updater_id,+ pipeline_id,+ environment_id,+ name+ )+VALUES+ (+ 10001,+ 101,+ 101,+ 9001,+ 5004,+ 'Prod'+ );++-- Stage for Pipeline 9002 simulating webhook push event+INSERT INTO+ stage (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ pipeline_id,+ environment_id,+ name+ )+VALUES+ (+ 10002,+ 1,+ 1624873710,+ 1,+ 1624873710,+ 9002,+ 5001,+ 'Dev'+ );++INSERT INTO+ stage (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ pipeline_id,+ environment_id,+ name+ )+VALUES+ (+ 10003,+ 1,+ 1624873710,+ 1,+ 1624873710,+ 9002,+ 5002,+ 'Integration'+ );++INSERT INTO+ stage (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ pipeline_id,+ environment_id,+ name+ )+VALUES+ (+ 10004,+ 1,+ 1624873710,+ 1,+ 1624873710,+ 9002,+ 5003,+ 'Staging'+ );++INSERT INTO+ stage (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ pipeline_id,+ environment_id,+ name+ )+VALUES+ (+ 10005,+ 1,+ 1624873710,+ 1,+ 1624873710,+ 9002,+ 5004,+ 'Prod'+ );++-- Stage for Pipeline 9003 create table+INSERT INTO+ stage (+ id,+ creator_id,+ updater_id,+ pipeline_id,+ environment_id,+ name+ )+VALUES+ (+ 10006,+ 103,+ 103,+ 9003,+ 5001,+ 'Dev'+ );++INSERT INTO+ stage (+ id,+ creator_id,+ updater_id,+ pipeline_id,+ environment_id,+ name+ )+VALUES+ (+ 10007,+ 103,+ 103,+ 9003,+ 5002,+ 'Integration'+ );++-- Stage for Pipeline 9004 simulating webhook push event+INSERT INTO+ stage (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ pipeline_id,+ environment_id,+ name+ )+VALUES+ (+ 10008,+ 1,+ 1624865387,+ 1,+ 1624865387,+ 9004,+ 5001,+ 'Dev'+ );++-- Stage for Pipeline 9005 simulating webhook push event+INSERT INTO+ stage (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ pipeline_id,+ environment_id,+ name+ )+VALUES+ (+ 10009,+ 1,+ 1624866790,+ 1,+ 1624866790,+ 9005,+ 5002,+ 'Integration'+ );++-- Stage for Pipeline 9006 simulating webhook push event+INSERT INTO+ stage (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ pipeline_id,+ environment_id,+ name+ )+VALUES+ (+ 10010,+ 1,+ 1624868407,+ 1,+ 1624868407,+ 9006,+ 5003,+ 'Staging'+ );++-- Stage for Pipeline 9007 simulating webhook push event+INSERT INTO+ stage (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ pipeline_id,+ environment_id,+ name+ )+VALUES+ (+ 10011,+ 1,+ 1624868680,+ 1,+ 1624868680,+ 9007,+ 5004,+ 'Prod'+ );++-- Stage for Pipeline 9008 simulating webhook push event+INSERT INTO+ stage (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ pipeline_id,+ environment_id,+ name+ )+VALUES+ (+ 10012,+ 1,+ 1624869944,+ 1,+ 1624869944,+ 9008,+ 5001,+ 'Dev'+ );++-- Stage for Pipeline 9009 multi-stage create table UI workflow+INSERT INTO+ stage (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ pipeline_id,+ environment_id,+ name+ )+VALUES+ (+ 10013,+ 103,+ 1624879944,+ 103,+ 1624879944,+ 9009,+ 5001,+ 'Dev'+ );++INSERT INTO+ stage (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ pipeline_id,+ environment_id,+ name+ )+VALUES+ (+ 10014,+ 103,+ 1624879944,+ 103,+ 1624879944,+ 9009,+ 5002,+ 'Integration'+ );++INSERT INTO+ stage (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ pipeline_id,+ environment_id,+ name+ )+VALUES+ (+ 10015,+ 103,+ 1624879944,+ 103,+ 1624879944,+ 9009,+ 5003,+ 'Staging'+ );++INSERT INTO+ stage (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ pipeline_id,+ environment_id,+ name+ )+VALUES+ (+ 10016,+ 103,+ 1624879944,+ 103,+ 1624879944,+ 9009,+ 5004,+ 'Prod'+ );++ALTER SEQUENCE stage_id_seq RESTART WITH 10017;diff --git a/store/pg_seed/test/10110__task.sql b/store/pg_seed/test/10110__task.sqlnew file mode 100644index 0000000000..5e4cb0ecf7--- /dev/null+++ b/store/pg_seed/test/10110__task.sql@@ -0,0 +1,521 @@+-- Task for Pipeline 9001 "Hello world", Stage 10001 "Prod" to update database 7014 "testdb_prod"+INSERT INTO+ task (+ id,+ creator_id,+ updater_id,+ pipeline_id,+ stage_id,+ instance_id,+ database_id,+ name,+ type,+ status,+ payload+ )+VALUES+ (+ 11001,+ 101,+ 101,+ 9001,+ 10001,+ 6004,+ 7014,+ 'Welcome',+ 'bb.task.general',+ 'PENDING_APPROVAL',+ '{"statement":"SELECT ''Welcome Tech Lead, DBA, Developer'';"}'+ );++-- Task for Pipeline 9002+-- Task for stage 10002 "Dev" to update database 7003 'shop'+INSERT INTO+ task (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ pipeline_id,+ stage_id,+ instance_id,+ database_id,+ name,+ type,+ status,+ payload+ )+VALUES+ (+ 11002,+ 1,+ 1624873710,+ 1,+ 1624873710,+ 9002,+ 10002,+ 6001,+ 7003,+ 'Add initial schema',+ 'bb.task.database.schema.update',+ 'DONE',+ '{"migrationType":"BASELINE","statement":"CREATE TABLE product (\n\tid INTEGER PRIMARY KEY AUTO_INCREMENT,\n\tname TEXT NOT NULL,\n\tdescription TEXT NOT NULL\n);\n","pushEvent":{"vcsType":"GITLAB_SELF_HOST","baseDir":"bytebase","ref":"refs/heads/master","repositoryId":"14","repositoryUrl":"http://gitlab.bytebase.com/bytebase-demo/shop","repositoryFullPath":"bytebase-demo/shop","authorName":"tianzhou","fileCommit":{"id":"c80352facbaefcde0c1c82340381be3286e5438d","title":"Create product table","message":"Create product table","createdTs":1624873354,"url":"http://gitlab.bytebase.com/bytebase-demo/shop/-/commit/c80352facbaefcde0c1c82340381be3286e5438d","authorName":"tianzhou","added":"bytebase/shop__v1__baseline__add_initial_schema.sql"}}}'+ );++-- Task for stage 10003 "Integration" to update database 7007 'shop'+INSERT INTO+ task (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ pipeline_id,+ stage_id,+ instance_id,+ database_id,+ name,+ type,+ status,+ payload+ )+VALUES+ (+ 11003,+ 1,+ 1624873710,+ 1,+ 1624873710,+ 9002,+ 10003,+ 6001,+ 7007,+ 'Add initial schema',+ 'bb.task.database.schema.update',+ 'DONE',+ '{"migrationType":"BASELINE","statement":"CREATE TABLE product (\n\tid INTEGER PRIMARY KEY AUTO_INCREMENT,\n\tname TEXT NOT NULL,\n\tdescription TEXT NOT NULL\n);\n","pushEvent":{"vcsType":"GITLAB_SELF_HOST","baseDir":"bytebase","ref":"refs/heads/master","repositoryId":"14","repositoryUrl":"http://gitlab.bytebase.com/bytebase-demo/shop","repositoryFullPath":"bytebase-demo/shop","authorName":"tianzhou","fileCommit":{"id":"c80352facbaefcde0c1c82340381be3286e5438d","title":"Create product table","message":"Create product table","createdTs":1624873354,"url":"http://gitlab.bytebase.com/bytebase-demo/shop/-/commit/c80352facbaefcde0c1c82340381be3286e5438d","authorName":"tianzhou","added":"bytebase/shop__v1__baseline__add_initial_schema.sql"}}}'+ );++-- Task for stage 10004 "Staging" to update database 7011 'shop'+INSERT INTO+ task (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ pipeline_id,+ stage_id,+ instance_id,+ database_id,+ name,+ type,+ status,+ payload+ )+VALUES+ (+ 11004,+ 1,+ 1624873710,+ 1,+ 1624873710,+ 9002,+ 10004,+ 6003,+ 7011,+ 'Add initial schema',+ 'bb.task.database.schema.update',+ 'PENDING_APPROVAL',+ '{"migrationType":"BASELINE","statement":"CREATE TABLE product (\n\tid INTEGER PRIMARY KEY AUTO_INCREMENT,\n\tname TEXT NOT NULL,\n\tdescription TEXT NOT NULL\n);\n","pushEvent":{"vcsType":"GITLAB_SELF_HOST","baseDir":"bytebase","ref":"refs/heads/master","repositoryId":"14","repositoryUrl":"http://gitlab.bytebase.com/bytebase-demo/shop","repositoryFullPath":"bytebase-demo/shop","authorName":"tianzhou","fileCommit":{"id":"c80352facbaefcde0c1c82340381be3286e5438d","title":"Create product table","message":"Create product table","createdTs":1624873354,"url":"http://gitlab.bytebase.com/bytebase-demo/shop/-/commit/c80352facbaefcde0c1c82340381be3286e5438d","authorName":"tianzhou","added":"bytebase/shop__v1__baseline__add_initial_schema.sql"}}}'+ );++-- Task for stage 10005 "Prod" to update database 7015 'proddb1'+INSERT INTO+ task (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ pipeline_id,+ stage_id,+ instance_id,+ database_id,+ name,+ type,+ status,+ payload+ )+VALUES+ (+ 11005,+ 1,+ 1624873710,+ 1,+ 1624873710,+ 9002,+ 10005,+ 6004,+ 7015,+ 'Add initial schema',+ 'bb.task.database.schema.update',+ 'PENDING_APPROVAL',+ '{"migrationType":"BASELINE","statement":"CREATE TABLE product (\n\tid INTEGER PRIMARY KEY AUTO_INCREMENT,\n\tname TEXT NOT NULL,\n\tdescription TEXT NOT NULL\n);\n","pushEvent":{"vcsType":"GITLAB_SELF_HOST","baseDir":"bytebase","ref":"refs/heads/master","repositoryId":"14","repositoryUrl":"http://gitlab.bytebase.com/bytebase-demo/shop","repositoryFullPath":"bytebase-demo/shop","authorName":"tianzhou","fileCommit":{"id":"c80352facbaefcde0c1c82340381be3286e5438d","title":"Create product table","message":"Create product table","createdTs":1624873354,"url":"http://gitlab.bytebase.com/bytebase-demo/shop/-/commit/c80352facbaefcde0c1c82340381be3286e5438d","authorName":"tianzhou","added":"bytebase/shop__v1__baseline__add_initial_schema.sql"}}}'+ );++-- Task for Pipeline 9003 create table+-- Task for stage 10006 "Dev" to craete table in database 7002 'testdb_dev'+INSERT INTO+ task (+ id,+ creator_id,+ updater_id,+ pipeline_id,+ stage_id,+ instance_id,+ database_id,+ name,+ type,+ status,+ payload+ )+VALUES+ (+ 11006,+ 103,+ 103,+ 9003,+ 10006,+ 6001,+ 7002,+ 'Update testdb_dev',+ 'bb.task.database.schema.update',+ 'FAILED',+ '{"migrationType":"MIGRATE","statement":"CREATE TABLE testdb_dev.tbl1 (name TEXT);", "rollbackStatement":"DROP TABLE testdb_dev.tbl1;"}'+ );++-- Task for stage 10003 "Integration" to update database 7006 'testdb_integration'+INSERT INTO+ task (+ id,+ creator_id,+ updater_id,+ pipeline_id,+ stage_id,+ instance_id,+ database_id,+ name,+ type,+ status,+ payload+ )+VALUES+ (+ 11007,+ 103,+ 103,+ 9003,+ 10007,+ 6001,+ 7006,+ 'Update testdb_integration',+ 'bb.task.database.schema.update',+ 'PENDING',+ '{"migrationType":"MIGRATE","statement":"CREATE TABLE testdb_integration.tbl1 (name TEXT);", "rollbackStatement":"DROP TABLE testdb_integration.tbl1;"}'+ );++-- Task for stage 10008 simulating webhook push event+INSERT INTO+ task (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ pipeline_id,+ stage_id,+ instance_id,+ database_id,+ name,+ type,+ status,+ payload+ )+VALUES+ (+ 11008,+ 1,+ 1624865387,+ 1,+ 1624865387,+ 9004,+ 10008,+ 6001,+ 7004,+ 'Add initial schema',+ 'bb.task.database.schema.update',+ 'DONE',+ '{"migrationType":"BASELINE","statement":"CREATE TABLE `user` (\n\tid INTEGER PRIMARY KEY AUTO_INCREMENT,\n\tname TEXT NOT NULL,\n\temail TEXT NOT NULL\n);\n\nCREATE TABLE post (\n\tid INTEGER PRIMARY KEY AUTO_INCREMENT,\n\tname TEXT NOT NULL,\n\tcontent TEXT NOT NULL,\n\tauthor_id INTEGER NOT NULL,\n\tFOREIGN KEY (author_id) REFERENCES `user` (id) ON DELETE RESTRICT\n);\n\nCREATE TABLE comment (\n\tid INTEGER PRIMARY KEY AUTO_INCREMENT,\n\tcontent TEXT NOT NULL,\n\tpost_id INTEGER NOT NULL,\n\tauthor_id INTEGER NOT NULL,\n\tFOREIGN KEY (post_id) REFERENCES post (id) ON DELETE CASCADE,\n\tFOREIGN KEY (author_id) REFERENCES `user` (id) ON DELETE RESTRICT\n);\n","pushEvent":{"vcsType":"GITLAB_SELF_HOST","baseDir":"bytebase","ref":"refs/heads/master","repositoryId":"13","repositoryUrl":"http://gitlab.bytebase.com/bytebase-demo/blog","repositoryFullPath":"bytebase-demo/blog","authorName":"tianzhou","fileCommit":{"id":"8f578d53e821c46421d69fd0aabd29921190a6c0","title":"Create user, post, comment table for dev environment","message":"Create user, post, comment table for dev environment","createdTs":1624865383,"url":"http://gitlab.bytebase.com/bytebase-demo/blog/-/commit/8f578d53e821c46421d69fd0aabd29921190a6c0","authorName":"tianzhou","added":"bytebase/dev/blog__202106280000__baseline__add_initial_schema.sql"}}}'+ );++-- Task for stage 10009 simulating webhook push event+INSERT INTO+ task (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ pipeline_id,+ stage_id,+ instance_id,+ database_id,+ name,+ type,+ status,+ payload+ )+VALUES+ (+ 11009,+ 1,+ 1624866790,+ 1,+ 1624866790,+ 9005,+ 10009,+ 6002,+ 7008,+ 'Add initial schema',+ 'bb.task.database.schema.update',+ 'DONE',+ '{"migrationType":"BASELINE","statement":"CREATE TABLE `user` (\n\tid INTEGER PRIMARY KEY AUTO_INCREMENT,\n\tname TEXT NOT NULL,\n\temail TEXT NOT NULL\n);\n\nCREATE TABLE post (\n\tid INTEGER PRIMARY KEY AUTO_INCREMENT,\n\tname TEXT NOT NULL,\n\tcontent TEXT NOT NULL,\n\tauthor_id INTEGER NOT NULL,\n\tFOREIGN KEY (author_id) REFERENCES `user` (id) ON DELETE RESTRICT\n);\n\nCREATE TABLE comment (\n\tid INTEGER PRIMARY KEY AUTO_INCREMENT,\n\tcontent TEXT NOT NULL,\n\tpost_id INTEGER NOT NULL,\n\tauthor_id INTEGER NOT NULL,\n\tFOREIGN KEY (post_id) REFERENCES post (id) ON DELETE CASCADE,\n\tFOREIGN KEY (author_id) REFERENCES `user` (id) ON DELETE RESTRICT\n);\n","pushEvent":{"vcsType":"GITLAB_SELF_HOST","baseDir":"bytebase","ref":"refs/heads/master","repositoryId":"13","repositoryUrl":"http://gitlab.bytebase.com/bytebase-demo/blog","repositoryFullPath":"bytebase-demo/blog","authorName":"tianzhou","fileCommit":{"id":"0765950c28c50dd07217aa0a133e8239e64f0ea1","title":"Create user, post, comment table for integration environment","message":"Create user, post, comment table for integration environment","createdTs":1624866787,"url":"http://gitlab.bytebase.com/bytebase-demo/blog/-/commit/0765950c28c50dd07217aa0a133e8239e64f0ea1","authorName":"tianzhou","added":"bytebase/integration/blog__202106280000__baseline__add_initial_schema.sql"}}}'+ );++-- Task for stage 10010 simulating webhook push event+INSERT INTO+ task (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ pipeline_id,+ stage_id,+ instance_id,+ database_id,+ name,+ type,+ status,+ payload+ )+VALUES+ (+ 11010,+ 1,+ 1624868407,+ 1,+ 1624868407,+ 9006,+ 10010,+ 6003,+ 7012,+ 'Add initial schema',+ 'bb.task.database.schema.update',+ 'DONE',+ '{"migrationType":"BASELINE","statement":"CREATE TABLE `user` (\n\tid INTEGER PRIMARY KEY AUTO_INCREMENT,\n\tname TEXT NOT NULL,\n\temail TEXT NOT NULL\n);\n\nCREATE TABLE post (\n\tid INTEGER PRIMARY KEY AUTO_INCREMENT,\n\tname TEXT NOT NULL,\n\tcontent TEXT NOT NULL,\n\tauthor_id INTEGER NOT NULL,\n\tFOREIGN KEY (author_id) REFERENCES `user` (id) ON DELETE RESTRICT\n);\n\nCREATE TABLE comment (\n\tid INTEGER PRIMARY KEY AUTO_INCREMENT,\n\tcontent TEXT NOT NULL,\n\tpost_id INTEGER NOT NULL,\n\tauthor_id INTEGER NOT NULL,\n\tFOREIGN KEY (post_id) REFERENCES post (id) ON DELETE CASCADE,\n\tFOREIGN KEY (author_id) REFERENCES `user` (id) ON DELETE RESTRICT\n);\n","pushEvent":{"vcsType":"GITLAB_SELF_HOST","baseDir":"bytebase","ref":"refs/heads/master","repositoryId":"13","repositoryUrl":"http://gitlab.bytebase.com/bytebase-demo/blog","repositoryFullPath":"bytebase-demo/blog","authorName":"tianzhou","fileCommit":{"id":"149f18b8d94805be4b92e256ef1dc9f4a27d5157","title":"Create user, post, comment table for staging environment","message":"Create user, post, comment table for staging environment","createdTs":1624868403,"url":"http://gitlab.bytebase.com/bytebase-demo/blog/-/commit/149f18b8d94805be4b92e256ef1dc9f4a27d5157","authorName":"tianzhou","added":"bytebase/bytebase/staging/blog__202106280000__baseline__add_initial_schema.sql"}}}'+ );++-- Task for stage 10011 simulating webhook push event+INSERT INTO+ task (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ pipeline_id,+ stage_id,+ instance_id,+ database_id,+ name,+ type,+ status,+ payload+ )+VALUES+ (+ 11011,+ 1,+ 1624868680,+ 1,+ 1624868680,+ 9007,+ 10011,+ 6004,+ 7016,+ 'Add initial schema',+ 'bb.task.database.schema.update',+ 'DONE',+ '{"migrationType":"BASELINE","statement":"CREATE TABLE `user` (\n\tid INTEGER PRIMARY KEY AUTO_INCREMENT,\n\tname TEXT NOT NULL,\n\temail TEXT NOT NULL\n);\n\nCREATE TABLE post (\n\tid INTEGER PRIMARY KEY AUTO_INCREMENT,\n\tname TEXT NOT NULL,\n\tcontent TEXT NOT NULL,\n\tauthor_id INTEGER NOT NULL,\n\tFOREIGN KEY (author_id) REFERENCES `user` (id) ON DELETE RESTRICT\n);\n\nCREATE TABLE comment (\n\tid INTEGER PRIMARY KEY AUTO_INCREMENT,\n\tcontent TEXT NOT NULL,\n\tpost_id INTEGER NOT NULL,\n\tauthor_id INTEGER NOT NULL,\n\tFOREIGN KEY (post_id) REFERENCES post (id) ON DELETE CASCADE,\n\tFOREIGN KEY (author_id) REFERENCES `user` (id) ON DELETE RESTRICT\n);\n","pushEvent":{"vcsType":"GITLAB_SELF_HOST","baseDir":"bytebase","ref":"refs/heads/master","repositoryId":"13","repositoryUrl":"http://gitlab.bytebase.com/bytebase-demo/blog","repositoryFullPath":"bytebase-demo/blog","authorName":"tianzhou","fileCommit":{"id":"ec17d38d6581015feb49b341cc3da56cb0e354fb","title":"Create user, post, comment table for prod environment","message":"Create user, post, comment table for prod environment","createdTs":1624868676,"url":"http://gitlab.bytebase.com/bytebase-demo/blog/-/commit/ec17d38d6581015feb49b341cc3da56cb0e354fb","authorName":"tianzhou","added":"bytebase/prod/blog__202106280000__baseline__add_initial_schema.sql"}}}'+ );++-- Task for stage 10012 simulating webhook push event+INSERT INTO+ task (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ pipeline_id,+ stage_id,+ instance_id,+ database_id,+ name,+ type,+ status,+ payload+ )+VALUES+ (+ 11012,+ 1,+ 1624869944,+ 1,+ 1624869944,+ 9008,+ 10012,+ 6001,+ 7004,+ 'Add created at column',+ 'bb.task.database.schema.update',+ 'FAILED',+ '{"migrationType":"MIGRATE","statement":"ALTER TABLE `user` ADD COLUMN `created_at` DATETIME NOT NULL;\n\nALTER TABLE post ADD COLUMN `created_at` DATETIME NOT NULL;\n\nALTER TABLE comment ADD COLUMN `created_at` DATETIME NOT NULL;\n","pushEvent":{"vcsType":"GITLAB_SELF_HOST","baseDir":"bytebase","ref":"refs/heads/master","repositoryId":"13","repositoryUrl":"http://gitlab.bytebase.com/bytebase-demo/blog","repositoryFullPath":"bytebase-demo/blog","authorName":"tianzhou","fileCommit":{"id":"8ff6482998059a861e1faa14658c65244577b54e","title":"Add created_at column to user,post,comment table for dev environment","message":"Add created_at column to user,post,comment table for dev environment","createdTs":1624869938,"url":"http://gitlab.bytebase.com/bytebase-demo/blog/-/commit/8ff6482998059a861e1faa14658c65244577b54e","authorName":"tianzhou","added":"bytebase/dev/blog__202106280100__migrate__add_created_at_column.sql"}}}'+ );++-- Task for Pipeline 9009 multi-stage create table UI workflow+-- Task for stage 10013 "Dev" to create table in database 7002 'testdb_dev'+INSERT INTO+ task (+ id,+ creator_id,+ updater_id,+ pipeline_id,+ stage_id,+ instance_id,+ database_id,+ name,+ type,+ status,+ payload+ )+VALUES+ (+ 11013,+ 103,+ 103,+ 9009,+ 10013,+ 6001,+ 7002,+ 'Update testdb_dev',+ 'bb.task.database.schema.update',+ 'DONE',+ '{"migrationType":"MIGRATE","statement":"CREATE TABLE testdb_dev.tbl2 (name TEXT);", "rollbackStatement":"DROP TABLE testdb_dev.tbl2;"}'+ );++-- Task for stage 10014 "Integration" to create table in database 7006 'testdb_integration'+INSERT INTO+ task (+ id,+ creator_id,+ updater_id,+ pipeline_id,+ stage_id,+ instance_id,+ database_id,+ name,+ type,+ status,+ payload+ )+VALUES+ (+ 11014,+ 103,+ 103,+ 9009,+ 10014,+ 6002,+ 7006,+ 'Update testdb_integration',+ 'bb.task.database.schema.update',+ 'DONE',+ '{"migrationType":"MIGRATE","statement":"CREATE TABLE testdb_integration.tbl2 (name TEXT);", "rollbackStatement":"DROP TABLE testdb_integration.tbl2;"}'+ );+++-- Task for stage 10015 "Integration" to create table in database 7010 'testdb_staging'+INSERT INTO+ task (+ id,+ creator_id,+ updater_id,+ pipeline_id,+ stage_id,+ instance_id,+ database_id,+ name,+ type,+ status,+ payload+ )+VALUES+ (+ 11015,+ 103,+ 103,+ 9009,+ 10015,+ 6003,+ 7010,+ 'Update testdb_staging',+ 'bb.task.database.schema.update',+ 'FAILED',+ '{"migrationType":"MIGRATE","statement":"CREATE TABLE testdb_staging.tbl2 (name TEXT);", "rollbackStatement":"DROP TABLE testdb_staging.tbl2;"}'+ );++-- Task for stage 10016 "prod" to create table in database 7014 'testdb_prod'+INSERT INTO+ task (+ id,+ creator_id,+ updater_id,+ pipeline_id,+ stage_id,+ instance_id,+ database_id,+ name,+ type,+ status,+ payload+ )+VALUES+ (+ 11016,+ 103,+ 103,+ 9009,+ 10016,+ 6004,+ 7014,+ 'Update testdb_prod',+ 'bb.task.database.schema.update',+ 'PENDING_APPROVAL',+ '{"migrationType":"MIGRATE","statement":"CREATE TABLE testdb_prod.tbl2 (name TEXT);", "rollbackStatement":"DROP TABLE testdb_prod.tbl2;"}'+ );++ALTER SEQUENCE task_id_seq RESTART WITH 11017;diff --git a/store/pg_seed/test/10120__task_run.sql b/store/pg_seed/test/10120__task_run.sqlnew file mode 100644index 0000000000..7d5c9b4955--- /dev/null+++ b/store/pg_seed/test/10120__task_run.sql@@ -0,0 +1,325 @@+ALTER SEQUENCE task_run_id_seq RESTART WITH 100;++-- Task run for task 11002+INSERT INTO+ task_run (+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ task_id,+ name,+ status,+ type,+ code,+ result,+ payload+ )+VALUES+ (+ 1,+ 1624873710,+ 1,+ 1624873710,+ 11002,+ 'Add initial schema 1624873710',+ 'DONE',+ 'bb.task.database.schema.update',+ 0,+ '{"detail":"Established baseline version 202106280000 for database ''shop''","migrationId":1,"version":"202106280000"}',+ '{"migrationType":"BASELINE","statement":"CREATE TABLE product (\n\tid INTEGER PRIMARY KEY AUTO_INCREMENT,\n\tname TEXT NOT NULL,\n\tdescription TEXT NOT NULL\n);\n","pushEvent":{"vcsType":"GITLAB_SELF_HOST","baseDir":"bytebase","ref":"refs/heads/master","repositoryId":"14","repositoryUrl":"http://gitlab.bytebase.com/bytebase-demo/shop","repositoryFullPath":"bytebase-demo/shop","authorName":"tianzhou","fileCommit":{"id":"c80352facbaefcde0c1c82340381be3286e5438d","title":"Create product table","message":"Create product table","createdTs":1624873354,"url":"http://gitlab.bytebase.com/bytebase-demo/shop/-/commit/c80352facbaefcde0c1c82340381be3286e5438d","authorName":"tianzhou","added":"bytebase/shop__v1__baseline__add_initial_schema.sql"}}}'+ );++-- Task run for task 11003+INSERT INTO+ task_run (+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ task_id,+ name,+ status,+ type,+ code,+ result,+ payload+ )+VALUES+ (+ 1,+ 1624883710,+ 1,+ 1624883710,+ 11003,+ 'Add initial schema 1624883710',+ 'DONE',+ 'bb.task.database.schema.update',+ 0,+ '{"detail":"Established baseline version 202106280000 for database ''shop''","migrationId":1,"version":"202106280000"}',+ '{"migrationType":"BASELINE","statement":"CREATE TABLE product (\n\tid INTEGER PRIMARY KEY AUTO_INCREMENT,\n\tname TEXT NOT NULL,\n\tdescription TEXT NOT NULL\n);\n","pushEvent":{"vcsType":"GITLAB_SELF_HOST","baseDir":"bytebase","ref":"refs/heads/master","repositoryId":"14","repositoryUrl":"http://gitlab.bytebase.com/bytebase-demo/shop","repositoryFullPath":"bytebase-demo/shop","authorName":"tianzhou","fileCommit":{"id":"c80352facbaefcde0c1c82340381be3286e5438d","title":"Create product table","message":"Create product table","createdTs":1624873354,"url":"http://gitlab.bytebase.com/bytebase-demo/shop/-/commit/c80352facbaefcde0c1c82340381be3286e5438d","authorName":"tianzhou","added":"bytebase/shop__v1__baseline__add_initial_schema.sql"}}}'+ );++-- Failed task run for task 11006 create table+INSERT INTO+ task_run (+ id,+ creator_id,+ updater_id,+ task_id,+ name,+ status,+ type,+ code,+ result+ )+VALUES+ (+ 12001,+ 101,+ 101,+ 11006,+ 'Update testdb_dev task run',+ 'FAILED',+ 'bb.task.database.schema.update',+ 103,+ '{"detail":"table \"tbl1\" already exists"}'+ );++-- Task run for task 11008+INSERT INTO+ task_run (+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ task_id,+ name,+ status,+ type,+ code,+ result,+ payload+ )+VALUES+ (+ 1,+ 1624865387,+ 1,+ 1624865387,+ 11008,+ 'Add initial schema 1624865387',+ 'DONE',+ 'bb.task.database.schema.update',+ 0,+ '{"detail":"Established baseline version 202106280000 for database ''blog''","migrationId":1,"version":"202106280000"}',+ '{"migrationType":"BASELINE","statement":"CREATE TABLE `user` (\n\tid INTEGER PRIMARY KEY AUTO_INCREMENT,\n\tname TEXT NOT NULL,\n\temail TEXT NOT NULL\n);\n\nCREATE TABLE post (\n\tid INTEGER PRIMARY KEY AUTO_INCREMENT,\n\tname TEXT NOT NULL,\n\tcontent TEXT NOT NULL,\n\tauthor_id INTEGER NOT NULL,\n\tFOREIGN KEY (author_id) REFERENCES `user` (id) ON DELETE RESTRICT\n);\n\nCREATE TABLE comment (\n\tid INTEGER PRIMARY KEY AUTO_INCREMENT,\n\tcontent TEXT NOT NULL,\n\tpost_id INTEGER NOT NULL,\n\tauthor_id INTEGER NOT NULL,\n\tFOREIGN KEY (post_id) REFERENCES post (id) ON DELETE CASCADE,\n\tFOREIGN KEY (author_id) REFERENCES `user` (id) ON DELETE RESTRICT\n);\n","pushEvent":{"vcsType":"GITLAB_SELF_HOST","baseDir":"bytebase","ref":"refs/heads/master","repositoryId":"13","repositoryUrl":"http://gitlab.bytebase.com/bytebase-demo/blog","repositoryFullPath":"bytebase-demo/blog","authorName":"tianzhou","fileCommit":{"id":"8f578d53e821c46421d69fd0aabd29921190a6c0","title":"Create user, post, comment table for dev environment","message":"Create user, post, comment table for dev environment","createdTs":1624865383,"url":"http://gitlab.bytebase.com/bytebase-demo/blog/-/commit/8f578d53e821c46421d69fd0aabd29921190a6c0","authorName":"tianzhou","added":"bytebase/dev/blog__202106280000__baseline__add_initial_schema.sql"}}}'+ );++-- Task run for task 11009+INSERT INTO+ task_run (+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ task_id,+ name,+ status,+ type,+ code,+ result,+ payload+ )+VALUES+ (+ 1,+ 1624866790,+ 1,+ 1624866790,+ 11009,+ 'Add initial schema 1624866790',+ 'DONE',+ 'bb.task.database.schema.update',+ 0,+ '{"detail":"Established baseline version 202106280000 for database ''blog''","migrationId":1,"version":"202106280000"}',+ '{"migrationType":"BASELINE","statement":"CREATE TABLE `user` (\n\tid INTEGER PRIMARY KEY AUTO_INCREMENT,\n\tname TEXT NOT NULL,\n\temail TEXT NOT NULL\n);\n\nCREATE TABLE post (\n\tid INTEGER PRIMARY KEY AUTO_INCREMENT,\n\tname TEXT NOT NULL,\n\tcontent TEXT NOT NULL,\n\tauthor_id INTEGER NOT NULL,\n\tFOREIGN KEY (author_id) REFERENCES `user` (id) ON DELETE RESTRICT\n);\n\nCREATE TABLE comment (\n\tid INTEGER PRIMARY KEY AUTO_INCREMENT,\n\tcontent TEXT NOT NULL,\n\tpost_id INTEGER NOT NULL,\n\tauthor_id INTEGER NOT NULL,\n\tFOREIGN KEY (post_id) REFERENCES post (id) ON DELETE CASCADE,\n\tFOREIGN KEY (author_id) REFERENCES `user` (id) ON DELETE RESTRICT\n);\n","pushEvent":{"vcsType":"GITLAB_SELF_HOST","baseDir":"bytebase","ref":"refs/heads/master","repositoryId":"13","repositoryUrl":"http://gitlab.bytebase.com/bytebase-demo/blog","repositoryFullPath":"bytebase-demo/blog","authorName":"tianzhou","fileCommit":{"id":"8f578d53e821c46421d69fd0aabd29921190a6c0","title":"Create user, post, comment table for dev environment","message":"Create user, post, comment table for dev environment","createdTs":1624865383,"url":"http://gitlab.bytebase.com/bytebase-demo/blog/-/commit/8f578d53e821c46421d69fd0aabd29921190a6c0","authorName":"tianzhou","added":"bytebase/dev/blog__202106280000__baseline__add_initial_schema.sql"}}}'+ );++-- Task run for task 11010+INSERT INTO+ task_run (+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ task_id,+ name,+ status,+ type,+ code,+ result,+ payload+ )+VALUES+ (+ 1,+ 1624868407,+ 1,+ 1624868407,+ 11010,+ 'Add initial schema 1624868407',+ 'DONE',+ 'bb.task.database.schema.update',+ 0,+ '{"detail":"Established baseline version 202106280000 for database ''blog''","migrationId":1,"version":"202106280000"}',+ '{"migrationType":"BASELINE","statement":"CREATE TABLE `user` (\n\tid INTEGER PRIMARY KEY AUTO_INCREMENT,\n\tname TEXT NOT NULL,\n\temail TEXT NOT NULL\n);\n\nCREATE TABLE post (\n\tid INTEGER PRIMARY KEY AUTO_INCREMENT,\n\tname TEXT NOT NULL,\n\tcontent TEXT NOT NULL,\n\tauthor_id INTEGER NOT NULL,\n\tFOREIGN KEY (author_id) REFERENCES `user` (id) ON DELETE RESTRICT\n);\n\nCREATE TABLE comment (\n\tid INTEGER PRIMARY KEY AUTO_INCREMENT,\n\tcontent TEXT NOT NULL,\n\tpost_id INTEGER NOT NULL,\n\tauthor_id INTEGER NOT NULL,\n\tFOREIGN KEY (post_id) REFERENCES post (id) ON DELETE CASCADE,\n\tFOREIGN KEY (author_id) REFERENCES `user` (id) ON DELETE RESTRICT\n);\n","pushEvent":{"vcsType":"GITLAB_SELF_HOST","baseDir":"bytebase","ref":"refs/heads/master","repositoryId":"13","repositoryUrl":"http://gitlab.bytebase.com/bytebase-demo/blog","repositoryFullPath":"bytebase-demo/blog","authorName":"tianzhou","fileCommit":{"id":"8f578d53e821c46421d69fd0aabd29921190a6c0","title":"Create user, post, comment table for dev environment","message":"Create user, post, comment table for dev environment","createdTs":1624865383,"url":"http://gitlab.bytebase.com/bytebase-demo/blog/-/commit/8f578d53e821c46421d69fd0aabd29921190a6c0","authorName":"tianzhou","added":"bytebase/dev/blog__202106280000__baseline__add_initial_schema.sql"}}}'+ );++-- Task run for task 11011+INSERT INTO+ task_run (+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ task_id,+ name,+ status,+ type,+ code,+ result,+ payload+ )+VALUES+ (+ 1,+ 1624868680,+ 1,+ 1624868680,+ 11011,+ 'Add initial schema 1624868680',+ 'DONE',+ 'bb.task.database.schema.update',+ 0,+ '{"detail":"Established baseline version 202106280000 for database ''blog''","migrationId":1,"version":"202106280000"}',+ '{"migrationType":"BASELINE","statement":"CREATE TABLE `user` (\n\tid INTEGER PRIMARY KEY AUTO_INCREMENT,\n\tname TEXT NOT NULL,\n\temail TEXT NOT NULL\n);\n\nCREATE TABLE post (\n\tid INTEGER PRIMARY KEY AUTO_INCREMENT,\n\tname TEXT NOT NULL,\n\tcontent TEXT NOT NULL,\n\tauthor_id INTEGER NOT NULL,\n\tFOREIGN KEY (author_id) REFERENCES `user` (id) ON DELETE RESTRICT\n);\n\nCREATE TABLE comment (\n\tid INTEGER PRIMARY KEY AUTO_INCREMENT,\n\tcontent TEXT NOT NULL,\n\tpost_id INTEGER NOT NULL,\n\tauthor_id INTEGER NOT NULL,\n\tFOREIGN KEY (post_id) REFERENCES post (id) ON DELETE CASCADE,\n\tFOREIGN KEY (author_id) REFERENCES `user` (id) ON DELETE RESTRICT\n);\n","pushEvent":{"vcsType":"GITLAB_SELF_HOST","baseDir":"bytebase","ref":"refs/heads/master","repositoryId":"13","repositoryUrl":"http://gitlab.bytebase.com/bytebase-demo/blog","repositoryFullPath":"bytebase-demo/blog","authorName":"tianzhou","fileCommit":{"id":"8f578d53e821c46421d69fd0aabd29921190a6c0","title":"Create user, post, comment table for dev environment","message":"Create user, post, comment table for dev environment","createdTs":1624865383,"url":"http://gitlab.bytebase.com/bytebase-demo/blog/-/commit/8f578d53e821c46421d69fd0aabd29921190a6c0","authorName":"tianzhou","added":"bytebase/dev/blog__202106280000__baseline__add_initial_schema.sql"}}}'+ );++-- Failed task run for task 11012 create table+INSERT INTO+ task_run (+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ task_id,+ name,+ status,+ type,+ code,+ result,+ payload+ )+VALUES+ (+ 1,+ 1624869944,+ 1,+ 1624869944,+ 11012,+ 'Add created at column 1624869944',+ 'FAILED',+ 'bb.task.database.schema.update',+ 201,+ '{"detail":"database ''blog'' has already applied version 202106280100"}',+ '{"migrationType":"MIGRATE","statement":"ALTER TABLE `user` ADD COLUMN `created_at` DATETIME NOT NULL;\n\nALTER TABLE post ADD COLUMN `created_at` DATETIME NOT NULL;\n\nALTER TABLE comment ADD COLUMN `created_at` DATETIME NOT NULL;\n","pushEvent":{"vcsType":"GITLAB_SELF_HOST","baseDir":"bytebase","ref":"refs/heads/master","repositoryId":"13","repositoryUrl":"http://gitlab.bytebase.com/bytebase-demo/blog","repositoryFullPath":"bytebase-demo/blog","authorName":"tianzhou","fileCommit":{"id":"8ff6482998059a861e1faa14658c65244577b54e","title":"Add created_at column to user,post,comment table for dev environment","message":"Add created_at column to user,post,comment table for dev environment","createdTs":1624869938,"url":"http://gitlab.bytebase.com/bytebase-demo/blog/-/commit/8ff6482998059a861e1faa14658c65244577b54e","authorName":"tianzhou","added":"bytebase/dev/blog__202106280100__migrate__add_created_at_column.sql"}}}'+ );++-- Successful task run for task 10013 create table+INSERT INTO+ task_run (+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ task_id,+ name,+ status,+ type,+ code,+ result,+ payload+ )+VALUES+ (+ 102,+ 1624879944,+ 102,+ 1624879944,+ 11013,+ 'Update testdb_dev task run',+ 'DONE',+ 'bb.task.database.schema.update',+ 0,+ '{"detail":"Applied migration version 20210830011437.11013 to database \"testdb_dev\"","migrationId":1,"version":"20210830011437.11013"}',+ '{"migrationType":"MIGRATE","statement":"CREATE TABLE testdb_dev.tbl2 (name TEXT)"}'+ );++-- Successful task run for task 10014 create table+INSERT INTO+ task_run (+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ task_id,+ name,+ status,+ type,+ result,+ payload+ )+VALUES+ (+ 102,+ 1624879944,+ 102,+ 1624879944,+ 11014,+ 'Update testdb_integration task run',+ 'DONE',+ 'bb.task.database.schema.update',+ '{"detail":"Applied migration version 20210830011437.11014 to database \"testdb_integration\"","migrationId":1,"version":"20210830011437.11014"}',+ '{"migrationType":"MIGRATE","statement":"CREATE TABLE testdb_integration.tbl2 (name TEXT)"}'+ );++-- Failed task run for task 10015 create table+INSERT INTO+ task_run (+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ task_id,+ name,+ status,+ type,+ code,+ result,+ payload+ )+VALUES+ (+ 102,+ 1624879944,+ 102,+ 1624879944,+ 11015,+ 'Update testdb_staging task run',+ 'FAILED',+ 'bb.task.database.schema.update',+ 103,+ '{"detail":"table \"tbl2\" already exists"}',+ '{"migrationType":"MIGRATE","statement":"CREATE TABLE testdb_staging.tbl2 (name TEXT)"}'+ );diff --git a/store/pg_seed/test/10121__task_check_run.sql b/store/pg_seed/test/10121__task_check_run.sqlnew file mode 100644index 0000000000..a411c1b6a9--- /dev/null+++ b/store/pg_seed/test/10121__task_check_run.sql@@ -0,0 +1,52 @@+ALTER SEQUENCE task_check_run_id_seq RESTART WITH 100;++-- Task run for task 11004+INSERT INTO+ task_check_run (+ creator_id,+ updater_id,+ task_id,+ status,+ type,+ code,+ comment,+ result,+ payload+ )+VALUES+ (+ 1,+ 1,+ 11004,+ 'FAILED',+ 'bb.task-check.database.connect',+ 101,+ 'failed to connect database "shop": failed to connect database On-premises Staging MySQL/shop at "mysql.staging.example.com":"3306" with user "admin": dial tcp: lookup mysql.staging.example.com: no such host',+ '',+ ''+ );++INSERT INTO+ task_check_run (+ creator_id,+ updater_id,+ task_id,+ status,+ type,+ code,+ comment,+ result,+ payload+ )+VALUES+ (+ 1,+ 1,+ 11004,+ 'DONE',+ 'bb.task-check.database.statement.syntax',+ 0,+ '',+ '{"resultList":[{"status":"SUCCESS","code":0,"title":"Syntax OK","content":"OK"}]}',+ '{"statement":"CREATE TABLE product (\n\tid INTEGER PRIMARY KEY AUTO_INCREMENT,\n\tname TEXT NOT NULL,\n\tdescription TEXT NOT NULL\n);\n","dbType":"MYSQL","charset":"utf8mb4","collation":"utf8mb4_general_ci"}'+ );diff --git a/store/pg_seed/test/10130__issue.sql b/store/pg_seed/test/10130__issue.sqlnew file mode 100644index 0000000000..316d21159e--- /dev/null+++ b/store/pg_seed/test/10130__issue.sql@@ -0,0 +1,277 @@+-- Issue for the single stage, single step "Hello world" pipeline+INSERT INTO+ issue (+ id,+ creator_id,+ updater_id,+ project_id,+ pipeline_id,+ name,+ status,+ type,+ description,+ assignee_id+ )+VALUES+ (+ 13001,+ 1,+ 1,+ 3001,+ 9001,+ 'Hello world!',+ 'OPEN',+ 'bb.issue.general',+ 'Welcome to Bytebase, this is the issue interface where developers and DBAs collaborate on database schema management issues such as: \n - Creating a new database\n - Creating a table\n - Creating an index\n - Adding/Altering a column\n - Troubleshooting performance issue\nLet''s try some simple tasks:\n1. Bookmark this issue by clicking the star icon on the top of this page\n2. Leave a comment below to greet future comers',+ 101+ );++-- Issue for simulating webhook push event to create table in multi-stage for shop project.+INSERT INTO+ issue (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ project_id,+ pipeline_id,+ name,+ status,+ type,+ description,+ assignee_id+ )+VALUES+ (+ 13002,+ 103,+ 1624873710,+ 103,+ 1624873710,+ 3002,+ 9002,+ 'Create product table using multi-stage VCS workflow',+ 'OPEN',+ 'bb.issue.database.schema.update',+ 'Create product table using multi-stage VCS workflow',+ 101+ );++-- Issue for the multi stage create table pipeline, first stage has a failed task run+INSERT INTO+ issue (+ id,+ creator_id,+ updater_id,+ project_id,+ pipeline_id,+ name,+ status,+ type,+ description,+ assignee_id+ )+VALUES+ (+ 13003,+ 103,+ 103,+ 3001,+ 9003,+ 'Create a new table ''tbl1''',+ 'CANCELED',+ 'bb.issue.database.schema.update',+ 'Create tbl1.',+ 102+ );++-- Issue for simulating webhook push event to create table for blog project dev database.+INSERT INTO+ issue (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ project_id,+ pipeline_id,+ name,+ status,+ type,+ description,+ assignee_id+ )+VALUES+ (+ 13004,+ 1,+ 1624865387,+ 1,+ 1624865387,+ 3003,+ 9004,+ 'Create user, post, comment table for dev environment',+ 'DONE',+ 'bb.issue.database.schema.update',+ 'Create user, post, comment table for dev environment',+ 1+ );++-- Issue for simulating webhook push event to create table for blog project integration database.+INSERT INTO+ issue (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ project_id,+ pipeline_id,+ name,+ status,+ type,+ description,+ assignee_id+ )+VALUES+ (+ 13005,+ 1,+ 1624866790,+ 1,+ 1624866790,+ 3003,+ 9005,+ 'Create user, post, comment table for integration environment',+ 'DONE',+ 'bb.issue.database.schema.update',+ 'Create user, post, comment table for integration environment',+ 1+ );++-- Issue for simulating webhook push event to create table for blog project staging database.+INSERT INTO+ issue (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ project_id,+ pipeline_id,+ name,+ status,+ type,+ description,+ assignee_id+ )+VALUES+ (+ 13006,+ 1,+ 1624868407,+ 1,+ 1624868407,+ 3003,+ 9006,+ 'Create user, post, comment table for staging environment',+ 'DONE',+ 'bb.issue.database.schema.update',+ 'Create user, post, comment table for staging environment',+ 1+ );++-- Issue for simulating webhook push event to create table for blog project prod database.+INSERT INTO+ issue (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ project_id,+ pipeline_id,+ name,+ status,+ type,+ description,+ assignee_id+ )+VALUES+ (+ 13007,+ 1,+ 1624868680,+ 1,+ 1624868680,+ 3003,+ 9007,+ 'Create user, post, comment table for prod environment',+ 'DONE',+ 'bb.issue.database.schema.update',+ 'Create user, post, comment table for prod environment',+ 1+ );++-- Issue for simulating webhook push event to alter table for blog project dev database.+INSERT INTO+ issue (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ project_id,+ pipeline_id,+ name,+ status,+ type,+ description,+ assignee_id+ )+VALUES+ (+ 13008,+ 1,+ 1624869944,+ 1,+ 1624869944,+ 3003,+ 9008,+ 'Add created_at column to user,post,comment table for dev environment',+ 'OPEN',+ 'bb.issue.database.schema.update',+ 'Add created_at column to user,post,comment table for dev environment',+ 1+ );++-- Issue for multi-stage create table UI workflow+INSERT INTO+ issue (+ id,+ creator_id,+ updater_id,+ project_id,+ pipeline_id,+ name,+ status,+ type,+ description,+ assignee_id+ )+VALUES+ (+ 13009,+ 103,+ 103,+ 3001,+ 9009,+ 'Create a new table ''tbl2'' using multi-stage SQL review workflow',+ 'CANCELED',+ 'bb.issue.database.schema.update',+ 'Create tbl2 using multi-stage SQL review workflow',+ 102+ );++ALTER SEQUENCE issue_id_seq RESTART WITH 13010;diff --git a/store/pg_seed/test/10131__issue_subscriber.sql b/store/pg_seed/test/10131__issue_subscriber.sqlnew file mode 100644index 0000000000..4c2735ed8b--- /dev/null+++ b/store/pg_seed/test/10131__issue_subscriber.sql@@ -0,0 +1,123 @@+-- Subscriber for issue 13001+INSERT INTO+ issue_subscriber (issue_id, subscriber_id)+VALUES+ (13001, 102);++INSERT INTO+ issue_subscriber (issue_id, subscriber_id)+VALUES+ (13001, 103);++INSERT INTO+ issue_subscriber (issue_id, subscriber_id)+VALUES+ (13001, 104);++-- Subscriber for issue 13002+INSERT INTO+ issue_subscriber (issue_id, subscriber_id)+VALUES+ (13002, 101);++INSERT INTO+ issue_subscriber (issue_id, subscriber_id)+VALUES+ (13002, 102);++-- Subscriber for issue 13003+INSERT INTO+ issue_subscriber (issue_id, subscriber_id)+VALUES+ (13003, 101);++INSERT INTO+ issue_subscriber (issue_id, subscriber_id)+VALUES+ (13003, 102);++INSERT INTO+ issue_subscriber (issue_id, subscriber_id)+VALUES+ (13003, 103);++INSERT INTO+ issue_subscriber (issue_id, subscriber_id)+VALUES+ (13003, 104);++-- Subscriber for issue 13004+INSERT INTO+ issue_subscriber (issue_id, subscriber_id)+VALUES+ (13004, 101);++INSERT INTO+ issue_subscriber (issue_id, subscriber_id)+VALUES+ (13004, 102);++INSERT INTO+ issue_subscriber (issue_id, subscriber_id)+VALUES+ (13004, 103);++INSERT INTO+ issue_subscriber (issue_id, subscriber_id)+VALUES+ (13004, 104);++-- Subscriber for issue 13005+INSERT INTO+ issue_subscriber (issue_id, subscriber_id)+VALUES+ (13005, 101);++-- Subscriber for issue 13006+INSERT INTO+ issue_subscriber (issue_id, subscriber_id)+VALUES+ (13006, 103);++INSERT INTO+ issue_subscriber (issue_id, subscriber_id)+VALUES+ (13006, 104);++-- Subscriber for issue 13007+INSERT INTO+ issue_subscriber (issue_id, subscriber_id)+VALUES+ (13007, 101);++INSERT INTO+ issue_subscriber (issue_id, subscriber_id)+VALUES+ (13007, 102);++-- Subscriber for issue 13008+INSERT INTO+ issue_subscriber (issue_id, subscriber_id)+VALUES+ (13008, 101);++INSERT INTO+ issue_subscriber (issue_id, subscriber_id)+VALUES+ (13007, 103);++-- Subscriber for issue 13009+INSERT INTO+ issue_subscriber (issue_id, subscriber_id)+VALUES+ (13009, 101);++INSERT INTO+ issue_subscriber (issue_id, subscriber_id)+VALUES+ (13009, 102);++INSERT INTO+ issue_subscriber (issue_id, subscriber_id)+VALUES+ (13009, 103);diff --git a/store/pg_seed/test/10140__activity.sql b/store/pg_seed/test/10140__activity.sqlnew file mode 100644index 0000000000..bbbb0f13e4--- /dev/null+++ b/store/pg_seed/test/10140__activity.sql@@ -0,0 +1,1276 @@+-- Activity for issue 13001+INSERT INTO+ activity (+ id,+ creator_id,+ updater_id,+ container_id,+ type,+ level,+ payload+ )+VALUES+ (+ 14001,+ 1,+ 1,+ 13001,+ 'bb.issue.create',+ 'INFO',+ '{"issueName":"Hello world!"}'+ );++INSERT INTO+ activity (+ id,+ creator_id,+ updater_id,+ container_id,+ type,+ level,+ comment,+ payload+ )+VALUES+ (+ 14002,+ 101,+ 101,+ 13001,+ 'bb.issue.comment.create',+ 'INFO',+ 'Welcome!',+ '{"issueName":"Hello world!"}'+ );++INSERT INTO+ activity (+ id,+ creator_id,+ updater_id,+ container_id,+ type,+ level,+ comment,+ payload+ )+VALUES+ (+ 14003,+ 102,+ 102,+ 13001,+ 'bb.issue.comment.create',+ 'INFO',+ 'Let''s rock!',+ '{"issueName":"Hello world!"}'+ );++INSERT INTO+ activity (+ id,+ creator_id,+ updater_id,+ container_id,+ type,+ level,+ comment,+ payload+ )+VALUES+ (+ 14004,+ 103,+ 103,+ 13001,+ 'bb.issue.comment.create',+ 'INFO',+ 'Go fish!',+ '{"issueName":"Hello world!"}'+ );++-- Activity for issue 13002+INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ payload+ )+VALUES+ (+ 14005,+ 1,+ 1624873710,+ 1,+ 1624873710,+ 13002,+ 'bb.issue.create',+ 'INFO',+ '{"issueName":"Create product table"}'+ );++INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14006,+ 1,+ 1624873710,+ 1,+ 1624873710,+ 13002,+ 'bb.pipeline.task.status.update',+ 'INFO',+ '',+ '{"taskId":11002,"oldStatus":"PENDING","newStatus":"RUNNING","issueName":"Create product table","taskName":"Add initial schema"}'+ );++INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14007,+ 1,+ 1624873710,+ 1,+ 1624873710,+ 13002,+ 'bb.pipeline.task.status.update',+ 'INFO',+ 'Established baseline version 202106280000 for database ''shop''',+ '{"taskId":11002,"oldStatus":"RUNNING","newStatus":"DONE"}'+ );++INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14008,+ 1,+ 1624873710,+ 1,+ 1624873710,+ 13002,+ 'bb.pipeline.task.status.update',+ 'INFO',+ '',+ '{"taskId":11003,"oldStatus":"PENDING","newStatus":"RUNNING"}'+ );++INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14009,+ 1,+ 1624873710,+ 1,+ 1624873710,+ 13002,+ 'bb.pipeline.task.status.update',+ 'INFO',+ 'Established baseline version 202106280000 for database ''shop''',+ '{"taskId":11003,"oldStatus":"RUNNING","newStatus":"DONE"}'+ );++INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ payload+ )+VALUES+ (+ 14010,+ 1,+ 1624873710,+ 1,+ 1624873710,+ 13002,+ 'bb.issue.field.update',+ 'INFO',+ '{"fieldId":"3","oldValue":"1","newValue":"101","issueName":"Create product table"}'+ );++-- Activity for issue 13003+INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ payload+ )+VALUES+ (+ 14011,+ 103,+ 1624873710,+ 103,+ 1624873710,+ 13003,+ 'bb.issue.create',+ 'INFO',+ '{"issueName":"CREATE a new TABLE ''tbl1''"}'+ );++-- Activity for failed task_run 12001+INSERT INTO+ activity (+ id,+ creator_id,+ updater_id,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14012,+ 1,+ 1,+ 13003,+ 'bb.pipeline.task.status.update',+ 'ERROR',+ 'table "tbl1" already exists',+ '{"taskId":11006,"oldStatus":"RUNNING","newStatus":"FAILED","issueName":"Create a new table ''tbl1''","taskName":"Update testdb_dev"}'+ );++INSERT INTO+ activity (+ id,+ creator_id,+ updater_id,+ container_id,+ type,+ level,+ payload+ )+VALUES+ (+ 14013,+ 102,+ 102,+ 13003,+ 'bb.issue.status.update',+ 'INFO',+ '{"oldStatus":"OPEN","newStatus":"CANCELED","issueName":"Create a new table ''tbl1''"}'+ );++-- Activity for issue 13004+INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14014,+ 1,+ 1624865387,+ 1,+ 1624865387,+ 13004,+ 'bb.issue.create',+ 'INFO',+ '',+ '{"issueName":"Create user, post, comment table for dev environment"}'+ );++INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14015,+ 1,+ 1624865388,+ 1,+ 1624865388,+ 13004,+ 'bb.pipeline.task.status.update',+ 'INFO',+ '',+ '{"taskId":11008,"oldStatus":"PENDING","newStatus":"RUNNING"}'+ );++INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14016,+ 1,+ 1624865388,+ 1,+ 1624865388,+ 13004,+ 'bb.pipeline.task.status.update',+ 'INFO',+ 'Established baseline version 202106280000 for database ''blog''',+ '{"taskId":11008,"oldStatus":"RUNNING","newStatus":"DONE"}'+ );++INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14017,+ 1,+ 1624865388,+ 1,+ 1624865388,+ 13004,+ 'bb.issue.status.update',+ 'INFO',+ '',+ '{"oldStatus":"RUNNING","newStatus":"DONE","issueName":"Create user, post, comment table for dev environment"}'+ );++-- Activity for issue 13005+INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14018,+ 1,+ 1624866790,+ 1,+ 1624866790,+ 13005,+ 'bb.issue.create',+ 'INFO',+ '',+ '{"issueName":"Create user, post, comment table for integration environment"}'+ );++INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14019,+ 1,+ 1624866791,+ 1,+ 1624866791,+ 13005,+ 'bb.pipeline.task.status.update',+ 'INFO',+ '',+ '{"taskId":11009,"oldStatus":"PENDING","newStatus":"RUNNING"}'+ );++INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14020,+ 1,+ 1624866791,+ 1,+ 1624866791,+ 13005,+ 'bb.pipeline.task.status.update',+ 'INFO',+ 'Established baseline version 202106280000 for database ''blog''',+ '{"taskId":11009,"oldStatus":"RUNNING","newStatus":"DONE"}'+ );++INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14021,+ 1,+ 1624866791,+ 1,+ 1624866791,+ 13005,+ 'bb.issue.status.update',+ 'INFO',+ '',+ '{"oldStatus":"RUNNING","newStatus":"DONE","issueName":"Create user, post, comment table for integration environment"}'+ );++-- Activity for issue 13006+INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14022,+ 1,+ 1624868407,+ 1,+ 1624868407,+ 13006,+ 'bb.issue.create',+ 'INFO',+ '',+ '{"issueName":"Create user, post, comment table for staging environment"}'+ );++INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14023,+ 1,+ 1624868408,+ 1,+ 1624868408,+ 13006,+ 'bb.pipeline.task.status.update',+ 'INFO',+ '',+ '{"taskId":11010,"oldStatus":"PENDING","newStatus":"RUNNING"}'+ );++INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14024,+ 1,+ 1624868408,+ 1,+ 1624868408,+ 13006,+ 'bb.pipeline.task.status.update',+ 'INFO',+ 'Established baseline version 202106280000 for database ''blog''',+ '{"taskId":11010,"oldStatus":"RUNNING","newStatus":"DONE"}'+ );++INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14025,+ 1,+ 1624868408,+ 1,+ 1624868408,+ 13006,+ 'bb.issue.status.update',+ 'INFO',+ '',+ '{"oldStatus":"RUNNING","newStatus":"DONE","issueName":"Create user, post, comment table for staging environment"}'+ );++-- Activity for issue 13007+INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14026,+ 1,+ 1624868680,+ 1,+ 1624868680,+ 13007,+ 'bb.issue.create',+ 'INFO',+ '',+ '{"issueName":"Create user, post, comment table for prod environment"}'+ );++INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14027,+ 1,+ 1624868681,+ 1,+ 1624868681,+ 13007,+ 'bb.pipeline.task.status.update',+ 'INFO',+ '',+ '{"taskId":11011,"oldStatus":"PENDING","newStatus":"RUNNING"}'+ );++INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14028,+ 1,+ 1624868681,+ 1,+ 1624868681,+ 13007,+ 'bb.pipeline.task.status.update',+ 'INFO',+ 'Established baseline version 202106280000 for database ''blog''',+ '{"taskId":11011,"oldStatus":"RUNNING","newStatus":"DONE"}'+ );++INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14029,+ 1,+ 1624868681,+ 1,+ 1624868681,+ 13007,+ 'bb.issue.status.update',+ 'INFO',+ '',+ '{"oldStatus":"RUNNING","newStatus":"DONE","issueName":"Create user, post, comment table for prod environment"}'+ );++-- Activity for issue 13008+INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14030,+ 1,+ 1624869944,+ 1,+ 1624869944,+ 13008,+ 'bb.issue.create',+ 'INFO',+ '',+ '{"issueName":"Add created_at column to user,post,comment table for dev environment"}'+ );++INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14031,+ 1,+ 1624869945,+ 1,+ 1624869945,+ 13008,+ 'bb.pipeline.task.status.update',+ 'INFO',+ '',+ '{"taskId":11012,"oldStatus":"PENDING","newStatus":"RUNNING"}'+ );++INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14032,+ 1,+ 1624869945,+ 1,+ 1624869945,+ 13008,+ 'bb.pipeline.task.status.update',+ 'ERROR',+ 'database ''blog'' has already applied version 202106280100',+ '{"taskId":11012,"oldStatus":"RUNNING","newStatus":"FAILED"}'+ );++-- Activity for issue 13009+INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14033,+ 103,+ 1624879944,+ 103,+ 1624879944,+ 13009,+ 'bb.issue.create',+ 'INFO',+ '',+ '{"issueName":"Create a new table ''tbl2'' using multi-stage SQL review workflow"}'+ );++INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14034,+ 102,+ 1624879944,+ 102,+ 1624879944,+ 13009,+ 'bb.pipeline.task.status.update',+ 'INFO',+ '',+ '{"taskId":11015,"oldStatus":"PENDING","newStatus":"RUNNING","issueName":"Create a new table ''tbl2'' using multi-stage SQL review workflow","taskName":"Update testdb_dev"}'+ );++INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14035,+ 102,+ 1624879944,+ 102,+ 1624879944,+ 13009,+ 'bb.pipeline.task.status.update',+ 'INFO',+ 'Applied migration version 20210830011437.11013 to database "testdb_dev"',+ '{"taskId":11013,"oldStatus":"RUNNING","newStatus":"DONE","issueName":"Create a new table ''tbl2'' using multi-stage SQL review workflow","taskName":"Update testdb_dev"}'+ );++INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14036,+ 102,+ 1624879944,+ 102,+ 1624879944,+ 13009,+ 'bb.pipeline.task.status.update',+ 'INFO',+ '',+ '{"taskId":11014,"oldStatus":"PENDING","newStatus":"RUNNING","issueName":"Create a new table ''tbl2'' using multi-stage SQL review workflow","taskName":"Update testdb_integration"}'+ );++INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14037,+ 102,+ 1624879944,+ 102,+ 1624879944,+ 13009,+ 'bb.pipeline.task.status.update',+ 'INFO',+ 'Applied migration version 20210830011437.11014 to database "testdb_integration"',+ '{"taskId":11014,"oldStatus":"RUNNING","newStatus":"DONE","issueName":"Create a new table ''tbl2'' using multi-stage SQL review workflow","taskName":"Update testdb_integration"}'+ );++INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14038,+ 102,+ 1624879944,+ 102,+ 1624879944,+ 13009,+ 'bb.pipeline.task.status.update',+ 'INFO',+ '',+ '{"taskId":11015,"oldStatus":"PENDING","newStatus":"RUNNING","issueName":"Create a new table ''tbl2'' using multi-stage SQL review workflow","taskName":"Update testdb_staging"}'+ );++INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14039,+ 102,+ 1624879944,+ 102,+ 1624879944,+ 13009,+ 'bb.pipeline.task.status.update',+ 'ERROR',+ 'table "tbl2" already exists',+ '{"taskId":11015,"oldStatus":"RUNNING","newStatus":"FAILED","issueName":"Create a new table ''tbl2'' using multi-stage SQL review workflow","taskName":"Update testdb_staging"}'+ );++-- Project activity for 3001+INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14040,+ 102,+ 1624879944,+ 102,+ 1624879944,+ 3001,+ 'bb.project.member.role.update',+ 'INFO',+ 'Changed Demo Owner ([email protected]) from OWNER to DEVELOPER.',+ ''+ );++-- Project activity for 3002+INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14041,+ 101,+ 1624879944,+ 101,+ 1624879944,+ 3002,+ 'bb.project.member.create',+ 'INFO',+ 'Granted Jerry DBA to [email protected] (DEVELOPER).',+ ''+ );++INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14042,+ 1,+ 1624879944,+ 1,+ 1624879944,+ 3002,+ 'bb.project.repository.push',+ 'INFO',+ 'Created issue "Create product table using multi-stage VCS workflow".',+ '{"pushEvent":{"vcsType":"GITLAB_SELF_HOST","baseDir":"bytebase","ref":"refs/heads/master","repositoryId":"14","repositoryUrl":"http://gitlab.bytebase.com/bytebase-demo/shop","repositoryFullPath":"bytebase-demo/shop","authorName":"tianzhou","fileCommit":{"id":"c80352facbaefcde0c1c82340381be3286e5438d","title":"Create product table","message":"Create product table","createdTs": 1630940811,"url":"https://gitlab.bytebase.com/bytebase-demo/shop/-/commit/c80352facbaefcde0c1c82340381be3286e5438d","authorName":"tianzhou","added":"bytebase/shop__v1__baseline__add_initial_schema.sql"}},"issueId":13002,"issueName":"Create product table using multi-stage VCS workflow"}'+ );++-- Project activity for 3003+INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14043,+ 101,+ 1624879944,+ 101,+ 1624879944,+ 3003,+ 'bb.project.member.create',+ 'INFO',+ 'Granted Tom Dev to [email protected] (DEVELOPER).',+ ''+ );++INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14044,+ 1,+ 1624879944,+ 1,+ 1624879944,+ 3003,+ 'bb.project.repository.push',+ 'INFO',+ 'Created issue "Add created_at column to user,post,comment table for dev environment".',+ '{"pushEvent":{"vcsType":"GITLAB_SELF_HOST","baseDir":"bytebase","ref":"refs/heads/master","repositoryId":"13","repositoryUrl":"http://gitlab.bytebase.com/bytebase-demo/blog","repositoryFullPath":"bytebase-demo/blog","authorName":"tianzhou","fileCommit":{"id":"8ff6482998059a861e1faa14658c65244577b54e","title":"Add created_at column to user,post,comment table for dev environment","message":"Add created_at column to user,post,comment table for dev environment","createdTs":1630943211,"url":"https://gitlab.bytebase.com/bytebase-demo/blog/-/commit/8ff6482998059a861e1faa14658c65244577b54e","authorName":"tianzhou","added":"bytebase/dev/blog__202106280100__migrate__add_created_at_column.sql"}},"issueId":13008,"issueName":"Add created_at column to user,post,comment table for dev environment"}'+ );++INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14045,+ 1,+ 1624879944,+ 1,+ 1624879944,+ 3003,+ 'bb.project.repository.push',+ 'INFO',+ 'Created issue "Create user, post, comment table for dev environment".',+ '{"pushEvent":{"vcsType":"GITLAB_SELF_HOST","baseDir":"bytebase","ref":"refs/heads/master","repositoryId":"13","repositoryUrl":"http://gitlab.bytebase.com/bytebase-demo/blog","repositoryFullPath":"bytebase-demo/blog","authorName":"tianzhou","fileCommit":{"id":"8f578d53e821c46421d69fd0aabd29921190a6c0","title":"Create user, post, comment table for dev environment","message":"Create user, post, comment table for dev environment","createdTs": 1630941711,"url":"https://gitlab.bytebase.com/bytebase-demo/blog/-/commit/8f578d53e821c46421d69fd0aabd29921190a6c0","authorName":"tianzhou","added":"bytebase/dev/blog__202106280000__baseline__add_initial_schema.sql"}},"issueId":13004,"issueName":"Create user, post, comment table for dev environment"}'+ );++INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14046,+ 1,+ 1624879944,+ 1,+ 1624879944,+ 3003,+ 'bb.project.repository.push',+ 'INFO',+ 'Created issue "Create user, post, comment table for integration environment".',+ '{"pushEvent":{"vcsType":"GITLAB_SELF_HOST","baseDir":"bytebase","ref":"refs/heads/master","repositoryId":"13","repositoryUrl":"http://gitlab.bytebase.com/bytebase-demo/blog","repositoryFullPath":"bytebase-demo/blog","authorName":"tianzhou","fileCommit":{"id":"0765950c28c50dd07217aa0a133e8239e64f0ea1","title":"Create user, post, comment table for integration environment","message":"Create user, post, comment table for integration environment","createdTs": 1630941711,"url":"https://gitlab.bytebase.com/bytebase-demo/blog/-/commit/0765950c28c50dd07217aa0a133e8239e64f0ea1","authorName":"tianzhou","added":"bytebase/integration/blog__202106280000__baseline__add_initial_schema.sql"}},"issueId":13005,"issueName":"Create user, post, comment table for integration environment"}'+ );++INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14047,+ 1,+ 1624879944,+ 1,+ 1624879944,+ 3003,+ 'bb.project.repository.push',+ 'INFO',+ 'Created issue "Create user, post, comment table for staging environment".',+ '{"pushEvent":{"vcsType":"GITLAB_SELF_HOST","baseDir":"bytebase","ref":"refs/heads/master","repositoryId":"13","repositoryUrl":"http://gitlab.bytebase.com/bytebase-demo/blog","repositoryFullPath":"bytebase-demo/blog","authorName":"tianzhou","fileCommit":{"id":"149f18b8d94805be4b92e256ef1dc9f4a27d5157","title":"Create user, post, comment table for staging environment","message":"Create user, post, comment table for staging environment","createdTs": 1630941711,"url":"https://gitlab.bytebase.com/bytebase-demo/blog/-/commit/149f18b8d94805be4b92e256ef1dc9f4a27d5157","authorName":"tianzhou","added":"bytebase/staging/blog__202106280000__baseline__add_initial_schema.sql"}},"issueId":13006,"issueName":"Create user, post, comment table for staging environment"}'+ );++INSERT INTO+ activity (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ container_id,+ type,+ level,+ COMMENT,+ payload+ )+VALUES+ (+ 14048,+ 1,+ 1624879944,+ 1,+ 1624879944,+ 3003,+ 'bb.project.repository.push',+ 'INFO',+ 'Created issue "Create user, post, comment table for prod environment".',+ '{"pushEvent":{"vcsType":"GITLAB_SELF_HOST","baseDir":"bytebase","ref":"refs/heads/master","repositoryId":"13","repositoryUrl":"http://gitlab.bytebase.com/bytebase-demo/blog","repositoryFullPath":"bytebase-demo/blog","authorName":"tianzhou","fileCommit":{"id":"ec17d38d6581015feb49b341cc3da56cb0e354fb","title":"Create user, post, comment table for prod environment","message":"Create user, post, comment table for prod environment","createdTs": 1630941711,"url":"https://gitlab.bytebase.com/bytebase-demo/blog/-/commit/ec17d38d6581015feb49b341cc3da56cb0e354fb","authorName":"tianzhou","added":"bytebase/prod/blog__202106280000__baseline__add_initial_schema.sql"}},"issueId":13006,"issueName":"Create user, post, comment table for prod environment"}'+ );++ALTER SEQUENCE activity_id_seq RESTART WITH 14049;diff --git a/store/pg_seed/test/10150__inbox.sql b/store/pg_seed/test/10150__inbox.sqlnew file mode 100644index 0000000000..3b10323ccc--- /dev/null+++ b/store/pg_seed/test/10150__inbox.sql@@ -0,0 +1,289 @@+-- Inbox for receiver 101+INSERT INTO+ inbox (+ id,+ receiver_id,+ activity_id,+ status+ )+VALUES+ (+ 15001,+ 101,+ 14001,+ 'READ'+ );++INSERT INTO+ inbox (+ id,+ receiver_id,+ activity_id,+ status+ )+VALUES+ (+ 15002,+ 101,+ 14003,+ 'UNREAD'+ );++INSERT INTO+ inbox (+ id,+ receiver_id,+ activity_id,+ status+ )+VALUES+ (+ 15003,+ 101,+ 14004,+ 'UNREAD'+ );++INSERT INTO+ inbox (+ id,+ receiver_id,+ activity_id,+ status+ )+VALUES+ (+ 15004,+ 101,+ 14005,+ 'UNREAD'+ );++INSERT INTO+ inbox (+ id,+ receiver_id,+ activity_id,+ status+ )+VALUES+ (+ 15005,+ 101,+ 14010,+ 'UNREAD'+ );++INSERT INTO+ inbox (+ id,+ receiver_id,+ activity_id,+ status+ )+VALUES+ (+ 15006,+ 101,+ 14012,+ 'UNREAD'+ );++INSERT INTO+ inbox (+ id,+ receiver_id,+ activity_id,+ status+ )+VALUES+ (+ 15007,+ 101,+ 14013,+ 'UNREAD'+ );++-- Inbox for receiver 102+INSERT INTO+ inbox (+ id,+ receiver_id,+ activity_id,+ status+ )+VALUES+ (+ 15008,+ 102,+ 14001,+ 'READ'+ );++INSERT INTO+ inbox (+ id,+ receiver_id,+ activity_id,+ status+ )+VALUES+ (+ 15009,+ 102,+ 14002,+ 'READ'+ );++INSERT INTO+ inbox (+ id,+ receiver_id,+ activity_id,+ status+ )+VALUES+ (+ 15010,+ 102,+ 14004,+ 'READ'+ );++INSERT INTO+ inbox (+ id,+ receiver_id,+ activity_id,+ status+ )+VALUES+ (+ 15011,+ 102,+ 14005,+ 'UNREAD'+ );++INSERT INTO+ inbox (+ id,+ receiver_id,+ activity_id,+ status+ )+VALUES+ (+ 15012,+ 102,+ 14006,+ 'UNREAD'+ );++INSERT INTO+ inbox (+ id,+ receiver_id,+ activity_id,+ status+ )+VALUES+ (+ 15013,+ 102,+ 14013,+ 'UNREAD'+ );++-- Inbox for receiver 103+INSERT INTO+ inbox (+ id,+ receiver_id,+ activity_id,+ status+ )+VALUES+ (+ 15014,+ 103,+ 14001,+ 'READ'+ );++INSERT INTO+ inbox (+ id,+ receiver_id,+ activity_id,+ status+ )+VALUES+ (+ 15015,+ 103,+ 14002,+ 'READ'+ );++INSERT INTO+ inbox (+ id,+ receiver_id,+ activity_id,+ status+ )+VALUES+ (+ 15016,+ 103,+ 14003,+ 'READ'+ );++INSERT INTO+ inbox (+ id,+ receiver_id,+ activity_id,+ status+ )+VALUES+ (+ 15017,+ 103,+ 14005,+ 'READ'+ );++INSERT INTO+ inbox (+ id,+ receiver_id,+ activity_id,+ status+ )+VALUES+ (+ 15018,+ 103,+ 14006,+ 'UNREAD'+ );++INSERT INTO+ inbox (+ id,+ receiver_id,+ activity_id,+ status+ )+VALUES+ (+ 15019,+ 103,+ 14013,+ 'UNREAD'+ );++ALTER SEQUENCE inbox_id_seq RESTART WITH 15020;diff --git a/store/pg_seed/test/10160__bookmark.sql b/store/pg_seed/test/10160__bookmark.sqlnew file mode 100644index 0000000000..ab8354b7c5--- /dev/null+++ b/store/pg_seed/test/10160__bookmark.sql@@ -0,0 +1,19 @@+-- Bookmark for issue 13001 "Hello world"+INSERT INTO+ bookmark (+ id,+ creator_id,+ updater_id,+ name,+ link+ )+VALUES+ (+ 16001,+ 101,+ 101,+ 'Hello world!',+ '/issue/hello-world-13001'+ );++ALTER SEQUENCE bookmark_id_seq RESTART WITH 16002;diff --git a/store/pg_seed/test/10170__vcs.sql b/store/pg_seed/test/10170__vcs.sqlnew file mode 100644index 0000000000..7122ce7c18--- /dev/null+++ b/store/pg_seed/test/10170__vcs.sql@@ -0,0 +1,27 @@+-- This is for demo purpose and the applciation_id has alraedy been deleted+INSERT INTO+ vcs (+ id,+ creator_id,+ updater_id,+ name,+ type,+ instance_url,+ api_url,+ application_id,+ secret+ )+VALUES+ (+ 17001,+ 101,+ 101,+ 'bytebase.gitlab.com',+ 'GITLAB_SELF_HOST',+ 'https://gitlab.bytebase.com',+ 'https://gitlab.bytebase.com/api/v4',+ 'fda62e44b5388b1ca6e72d5a7028a3c2c47157fc13fd98328e2bd446fae98fd8',+ '4ac5cf6f2e400398e34f753a5222432838e84349e8d5120c4adaa6a65278b765'+ );++ALTER SEQUENCE vcs_id_seq RESTART WITH 17002;diff --git a/store/pg_seed/test/10180__repository.sql b/store/pg_seed/test/10180__repository.sqlnew file mode 100644index 0000000000..0daf1bec99--- /dev/null+++ b/store/pg_seed/test/10180__repository.sql@@ -0,0 +1,150 @@+-- This is for demo purpose and the webhook has already been deleted+INSERT INTO+ repository (+ id,+ creator_id,+ updater_id,+ vcs_id,+ project_id,+ name,+ full_path,+ web_url,+ branch_filter,+ base_directory,+ file_path_template,+ schema_path_template,+ external_id,+ external_webhook_id,+ webhook_url_host,+ webhook_endpoint_id,+ webhook_secret_token,+ access_token,+ expires_ts,+ refresh_token+ )+VALUES+ (+ 18001,+ 101,+ 101,+ 17001,+ 3003,+ 'Blog',+ 'bytebase-demo/blog',+ 'http://gitlab.bytebase.com/bytebase-demo/blog',+ 'master',+ 'bytebase',+ '{{ENV_NAME}}/{{DB_NAME}}__{{VERSION}}__{{TYPE}}__{{DESCRIPTION}}.sql',+ '{{ENV_NAME}}/.{{DB_NAME}}__LATEST.sql',+ -- Refers to the bytebase-demo/blog+ '13',+ -- Refers to the webhook in bytebase-demo/blog+ '60',+ 'https://demo.bytebase.com',+ 'e99bf622-7f58-4d6b-a5be-b97af313d7ea',+ 'xxxxxxxxxxxxxxxx',+ 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',+ 0,+ 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'+ );++INSERT INTO+ repository (+ id,+ creator_id,+ updater_id,+ vcs_id,+ project_id,+ name,+ full_path,+ web_url,+ branch_filter,+ base_directory,+ file_path_template,+ schema_path_template,+ external_id,+ external_webhook_id,+ webhook_url_host,+ webhook_endpoint_id,+ webhook_secret_token,+ access_token,+ expires_ts,+ refresh_token+ )+VALUES+ (+ 18002,+ 101,+ 101,+ 17001,+ 3002,+ 'Shop',+ 'bytebase-demo/shop',+ 'http://gitlab.bytebase.com/bytebase-demo/shop',+ 'master',+ 'bytebase',+ '{{ENV_NAME}}/{{DB_NAME}}__{{VERSION}}__{{TYPE}}__{{DESCRIPTION}}.sql',+ '{{ENV_NAME}}/.{{DB_NAME}}__LATEST.sql',+ -- Refers to the bytebase-demo/shop+ '14',+ -- Refers to the webhook in bytebase-demo/shop+ '61',+ 'https://demo.bytebase.com',+ 'c5e30130-7322-4f84-953a-d08168c047d1',+ 'xxxxxxxxxxxxxxxx',+ 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',+ 0,+ 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'+ );++-- This is for demo purpose and the webhook has already been deleted+INSERT INTO+ repository (+ id,+ creator_id,+ updater_id,+ vcs_id,+ project_id,+ name,+ full_path,+ web_url,+ branch_filter,+ base_directory,+ file_path_template,+ schema_path_template,+ external_id,+ external_webhook_id,+ webhook_url_host,+ webhook_endpoint_id,+ webhook_secret_token,+ access_token,+ expires_ts,+ refresh_token+ )+VALUES+ (+ 18003,+ 101,+ 101,+ 17001,+ 3005,+ 'Tenant',+ 'bytebase-demo/tenant',+ 'http://gitlab.bytebase.com/bytebase-demo/tenant',+ 'master',+ 'bytebase',+ '{{DB_NAME}}__{{VERSION}}__{{TYPE}}__{{DESCRIPTION}}.sql',+ '.{{DB_NAME}}__LATEST.sql',+ -- Refers to the bytebase-demo/tenant+ '15',+ -- Refers to the webhook in bytebase-demo/tenant+ '62',+ 'https://demo.bytebase.com',+ 'e48bf625-7f58-4d6b-a5be-b97af313d7ea',+ 'xxxxxxxxxxxxxxxx',+ 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',+ 0,+ 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'+ );++ALTER SEQUENCE repository_id_seq RESTART WITH 18004;diff --git a/store/pg_seed/test/10190__anomaly.sql b/store/pg_seed/test/10190__anomaly.sqlnew file mode 100644index 0000000000..829eb23330--- /dev/null+++ b/store/pg_seed/test/10190__anomaly.sql@@ -0,0 +1,125 @@+-- Database anomalies+INSERT INTO+ anomaly (+ id,+ creator_id,+ updater_id,+ instance_id,+ database_id,+ type,+ payload+ )+VALUES+ (+ 19001,+ 1,+ 1,+ 6004,+ 7014,+ 'bb.anomaly.database.connection',+ '{"detail":"failed to connect database at mysql.prod.example.com:3306 with user \"root\": dial tcp: lookup mysql.prod.example.com: no such host"}'+ );++INSERT INTO+ anomaly (+ id,+ creator_id,+ updater_id,+ instance_id,+ database_id,+ type,+ payload+ )+VALUES+ (+ 19002,+ 1,+ 1,+ 6004,+ 7014,+ 'bb.anomaly.database.backup.policy-violation',+ '{"environmentId":5004,"expectedSchedule":"DAILY","actualSchedule":"UNSET"}'+ );++INSERT INTO+ anomaly (+ id,+ creator_id,+ updater_id,+ instance_id,+ database_id,+ type,+ payload+ )+VALUES+ (+ 19003,+ 1,+ 1,+ 6003,+ 7012,+ 'bb.anomaly.database.connection',+ '{"detail":"failed to connect database at mysql.staging.example.com:3306 with user \"root\": dial tcp: lookup mysql.staging.example.com: no such host"}'+ );++INSERT INTO+ anomaly (+ id,+ creator_id,+ updater_id,+ instance_id,+ database_id,+ type,+ payload+ )+VALUES+ (+ 19004,+ 1,+ 1,+ 6003,+ 7012,+ 'bb.anomaly.database.backup.policy-violation',+ '{"environmentId":5003,"expectedSchedule":"WEEKLY","actualSchedule":"UNSET"}'+ );++-- Instance anomalies+INSERT INTO+ anomaly (+ id,+ creator_id,+ updater_id,+ instance_id,+ type,+ payload+ )+VALUES+ (+ 19005,+ 1,+ 1,+ 6004,+ 'bb.anomaly.instance.connection',+ '{"detail":"failed to connect database at mysql.prod.example.com:3306 with user \"root\": dial tcp: lookup mysql.prod.example.com: no such host"}'+ );++INSERT INTO+ anomaly (+ id,+ creator_id,+ updater_id,+ instance_id,+ type,+ payload+ )+VALUES+ (+ 19006,+ 1,+ 1,+ 6003,+ 'bb.anomaly.instance.connection',+ '{"detail":"failed to connect database at mysql.staging.example.com:3306 with user \"admin\": dial tcp: lookup mysql.staging.example.com: no such host"}'+ );++ALTER SEQUENCE anomaly_id_seq RESTART WITH 19007;diff --git a/store/pg_seed/test/10200__label.sql b/store/pg_seed/test/10200__label.sqlnew file mode 100644index 0000000000..126431adc4--- /dev/null+++ b/store/pg_seed/test/10200__label.sql@@ -0,0 +1,257 @@+-- Label keys.+INSERT INTO+ label_key (+ id,+ creator_id,+ updater_id,+ key+ )+VALUES+ (+ 20001,+ 1,+ 1,+ 'bb.location'+ );++INSERT INTO+ label_key (+ id,+ creator_id,+ updater_id,+ key+ )+VALUES+ (+ 20002,+ 1,+ 1,+ 'bb.tenant'+ );++ALTER SEQUENCE label_key_id_seq RESTART WITH 20003;++-- Label values.+INSERT INTO+ label_value (+ id,+ creator_id,+ updater_id,+ key,+ value+ )+VALUES+ (+ 20010,+ 1,+ 1,+ 'bb.location',+ 'earth'+ );++INSERT INTO+ label_value (+ id,+ creator_id,+ updater_id,+ key,+ value+ )+VALUES+ (+ 20011,+ 1,+ 1,+ 'bb.tenant',+ 'bytebase'+ );++INSERT INTO+ label_value (+ id,+ creator_id,+ updater_id,+ key,+ value+ )+VALUES+ (+ 20012,+ 1,+ 1,+ 'bb.tenant',+ 'tenant1'+ );++INSERT INTO+ label_value (+ id,+ creator_id,+ updater_id,+ key,+ value+ )+VALUES+ (+ 20013,+ 1,+ 1,+ 'bb.tenant',+ 'tenant2'+ );++ALTER SEQUENCE label_value_id_seq RESTART WITH 20014;++-- Database labels for database in tenant mode disabled project.+INSERT INTO+ db_label (+ id,+ creator_id,+ updater_id,+ database_id,+ key,+ value+ )+VALUES+ (+ 20021,+ 1,+ 1,+ 7002,+ 'bb.location',+ 'earth'+ );++INSERT INTO+ db_label (+ id,+ creator_id,+ updater_id,+ database_id,+ key,+ value+ )+VALUES+ (+ 20022,+ 1,+ 1,+ 7002,+ 'bb.tenant',+ 'bytebase'+ );++-- Database labels for database in tenant mode project.+INSERT INTO+ db_label (+ id,+ creator_id,+ updater_id,+ database_id,+ key,+ value+ )+VALUES+ (+ 20023,+ 1,+ 1,+ 7021,+ 'bb.location',+ 'earth'+ );++INSERT INTO+ db_label (+ id,+ creator_id,+ updater_id,+ database_id,+ key,+ value+ )+VALUES+ (+ 20024,+ 1,+ 1,+ 7022,+ 'bb.tenant',+ 'bytebase'+ );+INSERT INTO+ db_label (+ id,+ creator_id,+ updater_id,+ database_id,+ key,+ value+ )+VALUES+ (+ 20025,+ 1,+ 1,+ 7023,+ 'bb.location',+ 'earth'+ );++INSERT INTO+ db_label (+ id,+ creator_id,+ updater_id,+ database_id,+ key,+ value+ )+VALUES+ (+ 20026,+ 1,+ 1,+ 7024,+ 'bb.tenant',+ 'bytebase'+ );+INSERT INTO+ db_label (+ id,+ creator_id,+ updater_id,+ database_id,+ key,+ value+ )+VALUES+ (+ 20027,+ 1,+ 1,+ 7025,+ 'bb.tenant',+ 'tenant1'+ );++INSERT INTO+ db_label (+ id,+ creator_id,+ updater_id,+ database_id,+ key,+ value+ )+VALUES+ (+ 20028,+ 1,+ 1,+ 7026,+ 'bb.tenant',+ 'tenant2'+ );++ALTER SEQUENCE db_label_id_seq RESTART WITH 20029;diff --git a/store/pg_seed/test/10210__deployment_config.sql b/store/pg_seed/test/10210__deployment_config.sqlnew file mode 100644index 0000000000..2979a80525--- /dev/null+++ b/store/pg_seed/test/10210__deployment_config.sql@@ -0,0 +1,60 @@+-- Deployment config with regional deployments for tenant mode project.+INSERT INTO+ deployment_config (+ id,+ creator_id,+ updater_id,+ project_id,+ name,+ config+ )+VALUES+ (+ 21001,+ 101,+ 101,+ 3005,+ 'regional-1',+ '{"deployments":[{"name":"Dev Stage","spec":{"selector":{"matchExpressions":[{"key":"bb.environment","operator":"In","values":["Dev"]},{"key":"bb.location","operator":"In","values":["earth"]}]}}},{"name":"Integration Stage","spec":{"selector":{"matchExpressions":[{"key":"bb.environment","operator":"In","values":["Integration"]},{"key":"bb.tenant","operator":"Exists"}]}}}]}'+ );++INSERT INTO+ deployment_config (+ id,+ creator_id,+ updater_id,+ project_id,+ name,+ config+ )+VALUES+ (+ 21002,+ 101,+ 101,+ 3006,+ 'regional-2',+ '{"deployments":[{"name":"Dev Stage","spec":{"selector":{"matchExpressions":[{"key":"bb.environment","operator":"In","values":["Dev"]},{"key":"bb.location","operator":"In","values":["earth"]}]}}},{"name":"Integration Stage","spec":{"selector":{"matchExpressions":[{"key":"bb.environment","operator":"In","values":["Integration"]},{"key":"bb.tenant","operator":"Exists"}]}}}]}'+ );+++INSERT INTO+ deployment_config (+ id,+ creator_id,+ updater_id,+ project_id,+ name,+ config+ )+VALUES+ (+ 21003,+ 101,+ 101,+ 3007,+ 'db-pattern',+ '{"deployments":[{"name":"Dev Stage","spec":{"selector":{"matchExpressions":[{"key":"bb.environment","operator":"In","values":["Dev"]},{"key":"bb.tenant","operator":"In","values":["tenant1"]}]}}},{"name":"Integration Stage","spec":{"selector":{"matchExpressions":[{"key":"bb.environment","operator":"In","values":["Integration"]},{"key":"bb.tenant","operator":"Exists"}]}}}]}'+ );++ALTER SEQUENCE deployment_config_id_seq RESTART WITH 21004;diff --git a/store/pg_seed/test/README.md b/store/pg_seed/test/README.mdnew file mode 100644index 0000000000..c30cb3d170--- /dev/null+++ b/store/pg_seed/test/README.md@@ -0,0 +1,11 @@+This folder contains the seed data for test. The test seed data is used when NOT building with "release" tag or running with --demo. Test seed data is+reloaded everytime we start the application (by setting forceResetSeed in the dev profile from the code)++Each file represents the data for a particular table. The file name is something like YXXXX, where Y is the major version number and XXXX is the id+start sequence number for that table, reasons for doing this:++- Y (majar version number) corresponds to the major schema version the seed file applies to++- Code loads the seed data in lexical file order, thus we maintain an explict order about how seed data is loaded since there exists order dependency between tables.++- Because XXXX corresponds to the id prefix for the record, so we can identify the resource type by just looking the id, and catch errors that our code accidentally passes an ID for a different resource type.diff --git a/store/sqlite.go b/store/sqlite.goindex ecf1aa60bf..be9c9bd7f5 100644--- a/store/sqlite.go+++ b/store/sqlite.go@@ -58,6 +58,9 @@ var pgMigrationFS embed.FS//go:embed seedvar seedFS embed.FS+//go:embed pg_seed+var pgSeedFS embed.FS+// DB represents the database connection.type DB struct {Db *sql.DB@@ -143,6 +146,14 @@ func (db *DB) Open() (err error) {" Bytebase create the latest schema. If you are running in production and don't want to reset the data, you can contact [email protected] for help",err)}++ if err := db.pgSeed(verBefore, verAfter); err != nil {+ return fmt.Errorf("failed to seed: %w."++ " It could be Bytebase is running against an old Bytebase schema. If you are developing Bytebase, you can remove pgdata"++ " directory under the same directory where the bytebase binary resides. and restart again to let"++ " Bytebase create the latest schema. If you are running in production and don't want to reset the data, you can contact [email protected] for help",+ err)+ }}return nil@@ -197,6 +208,41 @@ func (db *DB) seed(verBefore, verAfter version) error {return nil}+// pgSeed loads the seed data for testing+func (db *DB) pgSeed(verBefore, verAfter version) error {+ db.l.Info(fmt.Sprintf("Seeding database from pg_%s, force: %t ...", db.seedDir, db.forceResetSeed))+ names, err := fs.Glob(pgSeedFS, fmt.Sprintf("pg_%s/*.sql", db.seedDir))+ if err != nil {+ return err+ }++ // We separate seed data for each table into their own seed file.+ // And there exists foreign key dependency among tables, so we+ // name the seed file as 10001_xxx.sql, 10002_xxx.sql. Here we sort+ // the file name so they are loaded accordingly.+ sort.Strings(names)++ // Loop over all seed files and execute them in order.+ for _, name := range names {+ versionPrefix := strings.Split(filepath.Base(name), "__")[0]+ version, err := strconv.Atoi(versionPrefix)+ if err != nil {+ return fmt.Errorf("invalid seed file format %s, expected number prefix", filepath.Base(name))+ }+ ver := versionFromInt(version)+ if db.forceResetSeed || ver.biggerThan(verBefore) && !ver.biggerThan(verAfter) {+ if err := db.pgSeedFile(name); err != nil {+ return fmt.Errorf("seed error: name=%q err=%w", name, err)+ }+ } else {+ db.l.Info(fmt.Sprintf("Skip this seed file: %s. The corresponding seed version %s is not in the applicable range (%s, %s].",+ name, ver, verBefore, verAfter))+ }+ }+ db.l.Info("Completed database seeding.")+ return nil+}+// seedFile runs a single seed file within a transaction.func (db *DB) seedFile(name string) error {db.l.Info(fmt.Sprintf("Seeding %s...", name))@@ -216,6 +262,25 @@ func (db *DB) seedFile(name string) error {return tx.Commit()}+// pgSeedFile runs a single seed file within a transaction.+func (db *DB) pgSeedFile(name string) error {+ db.l.Info(fmt.Sprintf("Seeding %s...", name))+ tx, err := db.PgDB.Begin()+ if err != nil {+ return err+ }+ defer tx.Rollback()++ // Read and execute migration file.+ if buf, err := fs.ReadFile(pgSeedFS, name); err != nil {+ return err+ } else if _, err := tx.Exec(string(buf)); err != nil {+ return err+ }++ return tx.Commit()+}+// migrate sets up migration tracking and executes pending migration files.//// Migration files are embedded in the sqlite/migration folder and are executed