Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

Add a demo mode and copy the dev seed to demo seed

天舟2b356e04f75a
diff --git a/backend/bin/server/cmd/root.go b/backend/bin/server/cmd/root.go
index 487d82ab17..ac0936c995 100644
--- a/backend/bin/server/cmd/root.go
+++ b/backend/bin/server/cmd/root.go
@@ -28,8 +28,8 @@ var (
Use: "bytebase",
Short: "Bytebase server",
Run: func(cmd *cobra.Command, args []string) {
- if mode != "release" && mode != "dev" {
- fmt.Fprintln(os.Stderr, fmt.Errorf("invalid --mode %s, expect \"release\" | \"dev\"", mode))
+ if mode != "release" && mode != "dev" && mode != "demo" {
+ fmt.Fprintln(os.Stderr, fmt.Errorf("invalid --mode %s, expect \"release\" | \"dev\" | \"demo\"", mode))
os.Exit(1)
}
// Trim trailing / in case user supplies
@@ -45,7 +45,7 @@ func Execute() error {
}
func init() {
- rootCmd.PersistentFlags().StringVar(&mode, "mode", "release", "mode which Bytebase is running under. release | dev")
+ rootCmd.PersistentFlags().StringVar(&mode, "mode", "release", "mode which Bytebase is running under. release | dev | demo")
rootCmd.PersistentFlags().StringVar(&host, "host", "http://localhost", "host where Bytebase is running. e.g. https://bytebase.example.com")
rootCmd.PersistentFlags().IntVar(&port, "port", 8080, "port where Bytebase is running. e.g. 8080")
rootCmd.PersistentFlags().StringVar(&dataDir, "data", "./data", "directory where Bytebase stores data.")
@@ -114,6 +114,11 @@ func newMain() *main {
logConfig: zap.NewProductionConfig(),
dsn: fmt.Sprintf("%s/bytebase.db", dataDir),
},
+ "demo": {
+ mode: "demo",
+ logConfig: zap.NewProductionConfig(),
+ dsn: fmt.Sprintf("%s/bytebase_demo.db", dataDir),
+ },
}[mode]
fmt.Println("-----Config BEGIN-----")
diff --git a/backend/store/seed/demo/0001_principal.sql b/backend/store/seed/demo/0001_principal.sql
new file mode 100644
index 0000000000..ca1b1a7eba
--- /dev/null
+++ b/backend/store/seed/demo/0001_principal.sql
@@ -0,0 +1,93 @@
+-- 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 (
+ creator_id,
+ updater_id,
+ `status`,
+ `type`,
+ name,
+ email,
+ password_hash
+ )
+VALUES
+ (
+ 1,
+ 1,
+ 'ACTIVE',
+ 'END_USER',
+ 'Demo Owner',
+ -- 1024
+ '$2a$10$/65QFlHOmDzXshEMt/qYuunbJrXtRLcaYDcRODbyOPa/9/N0N8Zc2'
+ );
+
+-- 102
+INSERT INTO
+ principal (
+ creator_id,
+ updater_id,
+ `status`,
+ `type`,
+ name,
+ email,
+ password_hash
+ )
+VALUES
+ (
+ 1,
+ 1,
+ 'ACTIVE',
+ 'END_USER',
+ 'Jerry DBA',
+ -- aaa
+ '$2a$10$a.o5.ELPUO8PKYGuWTSDseOqNssImU2b9qFgBaDKI7CKAKIhQYVfG'
+ );
+
+-- 103
+INSERT INTO
+ principal (
+ creator_id,
+ updater_id,
+ `status`,
+ `type`,
+ name,
+ email,
+ password_hash
+ )
+VALUES
+ (
+ 1,
+ 1,
+ 'ACTIVE',
+ 'END_USER',
+ 'Tom Dev',
+ -- aaa
+ '$2a$10$cB0QuMqG0Bmz/j1LDI2gXOqUXtp.Yd87zRus6zxR026RyiyuWeJye'
+ );
+
+-- 104
+INSERT INTO
+ principal (
+ creator_id,
+ updater_id,
+ `status`,
+ `type`,
+ name,
+ email,
+ password_hash
+ )
+VALUES
+ (
+ 1,
+ 1,
+ 'ACTIVE',
+ 'END_USER',
+ 'Jane Dev',
+ -- aaa
+ '$2a$10$DJ/T2SmdNiOAKXnuf.LQzenVYr4sIQSDu004Io1svmiRUmvAEMIw6'
+ );
\ No newline at end of file
diff --git a/backend/store/seed/demo/0010_workspace.sql b/backend/store/seed/demo/0010_workspace.sql
new file mode 100644
index 0000000000..e2c27b7230
--- /dev/null
+++ b/backend/store/seed/demo/0010_workspace.sql
@@ -0,0 +1 @@
+-- 0010 is reserved for workspace, but is not implemented yet.
\ No newline at end of file
diff --git a/backend/store/seed/demo/0020_member.sql b/backend/store/seed/demo/0020_member.sql
new file mode 100644
index 0000000000..c868a066ce
--- /dev/null
+++ b/backend/store/seed/demo/0020_member.sql
@@ -0,0 +1,43 @@
+INSERT INTO
+ member (
+ id,
+ creator_id,
+ updater_id,
+ role,
+ principal_id
+ )
+VALUES
+ (2001, 101, 101, 'OWNER', 101);
+
+INSERT INTO
+ member (
+ id,
+ creator_id,
+ updater_id,
+ role,
+ principal_id
+ )
+VALUES
+ (2002, 101, 101, 'DBA', 102);
+
+INSERT INTO
+ member (
+ id,
+ creator_id,
+ updater_id,
+ role,
+ principal_id
+ )
+VALUES
+ (2003, 101, 101, 'DEVELOPER', 103);
+
+INSERT INTO
+ member (
+ id,
+ creator_id,
+ updater_id,
+ role,
+ principal_id
+ )
+VALUES
+ (2004, 101, 101, 'DEVELOPER', 104);
\ No newline at end of file
diff --git a/backend/store/seed/demo/0030_project.sql b/backend/store/seed/demo/0030_project.sql
new file mode 100644
index 0000000000..8cfe0bed7a
--- /dev/null
+++ b/backend/store/seed/demo/0030_project.sql
@@ -0,0 +1,96 @@
+INSERT INTO
+ project (
+ id,
+ creator_id,
+ updater_id,
+ name,
+ `key`,
+ workflow_type
+ )
+VALUES
+ (
+ 3001,
+ 101,
+ 101,
+ 'project 1',
+ 'PRJ1',
+ 'VCS'
+ );
+
+INSERT INTO
+ project (
+ id,
+ creator_id,
+ updater_id,
+ name,
+ `key`,
+ workflow_type
+ )
+VALUES
+ (
+ 3002,
+ 101,
+ 101,
+ 'project 2',
+ 'PRJ2',
+ 'UI'
+ );
+
+INSERT INTO
+ project (
+ id,
+ creator_id,
+ updater_id,
+ name,
+ `key`,
+ workflow_type
+ )
+VALUES
+ (
+ 3003,
+ 101,
+ 101,
+ 'project 3',
+ 'PRJ3',
+ 'UI'
+ );
+
+INSERT INTO
+ project (
+ id,
+ creator_id,
+ updater_id,
+ name,
+ `key`,
+ workflow_type
+ )
+VALUES
+ (
+ 3004,
+ 101,
+ 101,
+ 'project 4',
+ 'PRJ4',
+ 'UI'
+ );
+
+INSERT INTO
+ project (
+ id,
+ row_status,
+ creator_id,
+ updater_id,
+ name,
+ `key`,
+ workflow_type
+ )
+VALUES
+ (
+ 3005,
+ 'ARCHIVED',
+ 101,
+ 101,
+ 'project 5',
+ 'PRJ5',
+ 'UI'
+ );
\ No newline at end of file
diff --git a/backend/store/seed/demo/0040_project_member.sql b/backend/store/seed/demo/0040_project_member.sql
new file mode 100644
index 0000000000..d62835f746
--- /dev/null
+++ b/backend/store/seed/demo/0040_project_member.sql
@@ -0,0 +1,213 @@
+-- Project 3001 membership
+INSERT INTO
+ project_member (
+ id,
+ creator_id,
+ updater_id,
+ project_id,
+ `role`,
+ principal_id
+ )
+VALUES
+ (
+ 4001,
+ 101,
+ 101,
+ 3001,
+ 'OWNER',
+ 102
+ );
+
+INSERT INTO
+ project_member (
+ id,
+ creator_id,
+ updater_id,
+ project_id,
+ `role`,
+ principal_id
+ )
+VALUES
+ (
+ 4002,
+ 101,
+ 101,
+ 3001,
+ 'DEVELOPER',
+ 101
+ );
+
+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',
+ 103
+ );
+
+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',
+ 102
+ );
+
+INSERT INTO
+ project_member (
+ id,
+ creator_id,
+ updater_id,
+ project_id,
+ `role`,
+ principal_id
+ )
+VALUES
+ (
+ 4007,
+ 101,
+ 101,
+ 3003,
+ 'DEVELOPER',
+ 101
+ );
+
+-- Project 3004 membership
+INSERT INTO
+ project_member (
+ id,
+ creator_id,
+ updater_id,
+ project_id,
+ `role`,
+ principal_id
+ )
+VALUES
+ (
+ 4008,
+ 101,
+ 101,
+ 3004,
+ 'OWNER',
+ 102
+ );
+
+INSERT INTO
+ project_member (
+ id,
+ creator_id,
+ updater_id,
+ project_id,
+ `role`,
+ principal_id
+ )
+VALUES
+ (
+ 4009,
+ 101,
+ 101,
+ 3004,
+ 'DEVELOPER',
+ 101
+ );
+
+-- Project 3005 membership
+INSERT INTO
+ project_member (
+ id,
+ creator_id,
+ updater_id,
+ project_id,
+ `role`,
+ principal_id
+ )
+VALUES
+ (
+ 4010,
+ 101,
+ 101,
+ 3005,
+ 'OWNER',
+ 101
+ );
+
+INSERT INTO
+ project_member (
+ id,
+ creator_id,
+ updater_id,
+ project_id,
+ `role`,
+ principal_id
+ )
+VALUES
+ (
+ 4011,
+ 101,
+ 101,
+ 3005,
+ 'DEVELOPER',
+ 103
+ );
\ No newline at end of file
diff --git a/backend/store/seed/demo/0050_environment.sql b/backend/store/seed/demo/0050_environment.sql
new file mode 100644
index 0000000000..f9d7a609dc
--- /dev/null
+++ b/backend/store/seed/demo/0050_environment.sql
@@ -0,0 +1,86 @@
+INSERT INTO
+ environment (
+ id,
+ creator_id,
+ updater_id,
+ name,
+ `order`
+ )
+VALUES
+ (
+ 5001,
+ 101,
+ 101,
+ 'Sandbox A',
+ 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
+ );
\ No newline at end of file
diff --git a/backend/store/seed/demo/0060_instance.sql b/backend/store/seed/demo/0060_instance.sql
new file mode 100644
index 0000000000..1d02f15000
--- /dev/null
+++ b/backend/store/seed/demo/0060_instance.sql
@@ -0,0 +1,124 @@
+INSERT INTO
+ instance (
+ id,
+ creator_id,
+ updater_id,
+ environment_id,
+ name,
+ `engine`,
+ external_link,
+ host,
+ port
+ )
+VALUES
+ (
+ 6001,
+ 101,
+ 101,
+ 5001,
+ 'MySQL sandbox',
+ 'MYSQL',
+ 'localhost',
+ '127.0.0.1',
+ '33060'
+ );
+
+INSERT INTO
+ instance (
+ id,
+ creator_id,
+ updater_id,
+ environment_id,
+ name,
+ `engine`,
+ external_link,
+ host,
+ port
+ )
+VALUES
+ (
+ 6002,
+ 101,
+ 101,
+ 5002,
+ 'MySQL integration',
+ 'MYSQL',
+ 'localhost',
+ '127.0.0.1',
+ '33060'
+ );
+
+INSERT INTO
+ instance (
+ id,
+ creator_id,
+ updater_id,
+ environment_id,
+ name,
+ `engine`,
+ external_link,
+ host,
+ port
+ )
+VALUES
+ (
+ 6003,
+ 101,
+ 101,
+ 5003,
+ 'MySQL staging',
+ 'MYSQL',
+ 'localhost',
+ '127.0.0.1',
+ '33060'
+ );
+
+INSERT INTO
+ instance (
+ id,
+ creator_id,
+ updater_id,
+ environment_id,
+ name,
+ `engine`,
+ external_link,
+ host,
+ port
+ )
+VALUES
+ (
+ 6004,
+ 101,
+ 101,
+ 5004,
+ 'MySQL prod',
+ 'MYSQL',
+ 'localhost',
+ '127.0.0.1',
+ '33060'
+ );
+
+INSERT INTO
+ instance (
+ id,
+ creator_id,
+ updater_id,
+ environment_id,
+ name,
+ `engine`,
+ external_link,
+ host,
+ port
+ )
+VALUES
+ (
+ 6005,
+ 101,
+ 101,
+ 5004,
+ 'AWS RDS prod',
+ 'MYSQL',
+ 'aws.com',
+ 'rds.com',
+ '5678'
+ );
\ No newline at end of file
diff --git a/backend/store/seed/demo/0070_db.sql b/backend/store/seed/demo/0070_db.sql
new file mode 100644
index 0000000000..0d1a60b2c6
--- /dev/null
+++ b/backend/store/seed/demo/0070_db.sql
@@ -0,0 +1,526 @@
+-- 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,
+ fingerprint
+ )
+VALUES
+ (
+ 7001,
+ 101,
+ 101,
+ 6001,
+ 1,
+ '*',
+ 'utf8mb4',
+ 'utf8mb4_0900_ai_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,
+ fingerprint
+ )
+VALUES
+ (
+ 7002,
+ 101,
+ 101,
+ 6001,
+ 3001,
+ 'sandboxdb1',
+ 'utf8mb4',
+ 'utf8mb4_0900_ai_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,
+ fingerprint
+ )
+VALUES
+ (
+ 7003,
+ 101,
+ 101,
+ 6001,
+ 3002,
+ 'sandboxdb2',
+ 'utf8mb4',
+ 'utf8mb4_0900_ai_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,
+ fingerprint
+ )
+VALUES
+ (
+ 7004,
+ 101,
+ 101,
+ 6001,
+ 3003,
+ 'sandboxdb3',
+ 'utf8mb4',
+ 'utf8mb4_0900_ai_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,
+ fingerprint
+ )
+VALUES
+ (
+ 7005,
+ 101,
+ 101,
+ 6002,
+ 1,
+ '*',
+ 'utf8mb4',
+ 'utf8mb4_0900_ai_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,
+ fingerprint
+ )
+VALUES
+ (
+ 7006,
+ 101,
+ 101,
+ 6002,
+ 3001,
+ 'integrationdb1',
+ 'utf8mb4',
+ 'utf8mb4_0900_ai_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,
+ fingerprint
+ )
+VALUES
+ (
+ 7007,
+ 101,
+ 101,
+ 6002,
+ 3002,
+ 'integrationdb2',
+ 'utf8mb4',
+ 'utf8mb4_0900_ai_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,
+ fingerprint
+ )
+VALUES
+ (
+ 7008,
+ 101,
+ 101,
+ 6002,
+ 3003,
+ 'integrationdb3',
+ 'utf8mb4',
+ 'utf8mb4_0900_ai_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,
+ fingerprint
+ )
+VALUES
+ (
+ 7009,
+ 101,
+ 101,
+ 6003,
+ 1,
+ '*',
+ 'utf8mb4',
+ 'utf8mb4_0900_ai_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,
+ fingerprint
+ )
+VALUES
+ (
+ 7010,
+ 101,
+ 101,
+ 6003,
+ 3001,
+ 'stagingdb1',
+ 'utf8mb4',
+ 'utf8mb4_0900_ai_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,
+ fingerprint
+ )
+VALUES
+ (
+ 7011,
+ 101,
+ 101,
+ 6003,
+ 3002,
+ 'stagingdb2',
+ 'utf8mb4',
+ 'utf8mb4_0900_ai_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,
+ fingerprint
+ )
+VALUES
+ (
+ 7012,
+ 101,
+ 101,
+ 6003,
+ 3003,
+ 'stagingdb3',
+ 'utf8mb4',
+ 'utf8mb4_0900_ai_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,
+ fingerprint
+ )
+VALUES
+ (
+ 7013,
+ 101,
+ 101,
+ 6004,
+ 1,
+ '*',
+ 'utf8mb4',
+ 'utf8mb4_0900_ai_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,
+ fingerprint
+ )
+VALUES
+ (
+ 7014,
+ 101,
+ 101,
+ 6004,
+ 3001,
+ 'proddb1',
+ 'utf8mb4',
+ 'utf8mb4_0900_ai_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,
+ fingerprint
+ )
+VALUES
+ (
+ 7015,
+ 101,
+ 101,
+ 6004,
+ 3002,
+ 'proddb2',
+ 'utf8mb4',
+ 'utf8mb4_0900_ai_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,
+ fingerprint
+ )
+VALUES
+ (
+ 7016,
+ 101,
+ 101,
+ 6004,
+ 3002,
+ 'proddb21',
+ 'utf8mb4',
+ 'utf8mb4_0900_ai_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,
+ fingerprint
+ )
+VALUES
+ (
+ 7017,
+ 101,
+ 101,
+ 6004,
+ 3003,
+ 'proddb3',
+ 'utf8mb4',
+ 'utf8mb4_0900_ai_ci',
+ 'OK',
+ 0,
+ ''
+ );
+
+-- Database for prod environment instance 6005
+INSERT INTO
+ db (
+ id,
+ creator_id,
+ updater_id,
+ instance_id,
+ project_id,
+ name,
+ character_set,
+ `collation`,
+ sync_status,
+ last_successful_sync_ts,
+ fingerprint
+ )
+VALUES
+ (
+ 7018,
+ 101,
+ 101,
+ 6005,
+ 1,
+ '*',
+ 'utf8mb4',
+ 'utf8mb4_0900_ai_ci',
+ 'OK',
+ 0,
+ ''
+ );
\ No newline at end of file
diff --git a/backend/store/seed/demo/0071_tbl.sql b/backend/store/seed/demo/0071_tbl.sql
new file mode 100644
index 0000000000..2bacb747fd
--- /dev/null
+++ b/backend/store/seed/demo/0071_tbl.sql
@@ -0,0 +1,2 @@
+-- tbl is populated via schema sync, so no seed data here.
+-- Creating this file just to reduce confusion in case people may wonder whether we miss the file.
\ No newline at end of file
diff --git a/backend/store/seed/demo/0080_data_source.sql b/backend/store/seed/demo/0080_data_source.sql
new file mode 100644
index 0000000000..4d3c7564e9
--- /dev/null
+++ b/backend/store/seed/demo/0080_data_source.sql
@@ -0,0 +1,124 @@
+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',
+ 'root'
+ );
+
+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',
+ 'root',
+ 'root'
+ );
+
+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',
+ 'root',
+ 'root'
+ );
+
+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',
+ 'root'
+ );
+
+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',
+ 'admin5',
+ 'adminpwd5'
+ );
\ No newline at end of file
diff --git a/backend/store/seed/demo/0090_pipeline.sql b/backend/store/seed/demo/0090_pipeline.sql
new file mode 100644
index 0000000000..6a60276155
--- /dev/null
+++ b/backend/store/seed/demo/0090_pipeline.sql
@@ -0,0 +1,71 @@
+-- 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 multi stage, each containing a single add column task
+INSERT INTO
+ pipeline (
+ id,
+ creator_id,
+ updater_id,
+ name,
+ `status`
+ )
+VALUES
+ (
+ 9002,
+ 103,
+ 103,
+ 'Pipeline - Add column ''location'' to table ''warehouse''',
+ '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''',
+ 'OPEN'
+ );
+
+-- A pipeline simulating webhook push event
+INSERT INTO
+ pipeline (
+ id,
+ creator_id,
+ updater_id,
+ name,
+ `status`
+ )
+VALUES
+ (
+ 9004,
+ 1,
+ 1,
+ 'Pipeline - Create todo table to staging db1',
+ 'OPEN'
+ );
\ No newline at end of file
diff --git a/backend/store/seed/demo/0100_stage.sql b/backend/store/seed/demo/0100_stage.sql
new file mode 100644
index 0000000000..45a36c8e34
--- /dev/null
+++ b/backend/store/seed/demo/0100_stage.sql
@@ -0,0 +1,155 @@
+-- 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 add column
+INSERT INTO
+ stage (
+ id,
+ creator_id,
+ updater_id,
+ pipeline_id,
+ environment_id,
+ name
+ )
+VALUES
+ (
+ 10002,
+ 103,
+ 103,
+ 9002,
+ 5001,
+ 'Sandbox A'
+ );
+
+INSERT INTO
+ stage (
+ id,
+ creator_id,
+ updater_id,
+ pipeline_id,
+ environment_id,
+ name
+ )
+VALUES
+ (
+ 10003,
+ 103,
+ 103,
+ 9002,
+ 5002,
+ 'Integration'
+ );
+
+INSERT INTO
+ stage (
+ id,
+ creator_id,
+ updater_id,
+ pipeline_id,
+ environment_id,
+ name
+ )
+VALUES
+ (
+ 10004,
+ 103,
+ 103,
+ 9002,
+ 5003,
+ 'Staging'
+ );
+
+INSERT INTO
+ stage (
+ id,
+ creator_id,
+ updater_id,
+ pipeline_id,
+ environment_id,
+ name
+ )
+VALUES
+ (
+ 10005,
+ 103,
+ 103,
+ 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,
+ 'Sandbox A'
+ );
+
+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,
+ updater_id,
+ pipeline_id,
+ environment_id,
+ name
+ )
+VALUES
+ (
+ 10008,
+ 1,
+ 1,
+ 9004,
+ 5003,
+ 'Staging'
+ );
\ No newline at end of file
diff --git a/backend/store/seed/demo/0110_task.sql b/backend/store/seed/demo/0110_task.sql
new file mode 100644
index 0000000000..6467f620c6
--- /dev/null
+++ b/backend/store/seed/demo/0110_task.sql
@@ -0,0 +1,241 @@
+-- Task for Pipeline 9001 "Hello world", Stage 10001 "Prod" to update database 7008 "proddb1"
+INSERT INTO
+ task (
+ id,
+ creator_id,
+ updater_id,
+ pipeline_id,
+ stage_id,
+ instance_id,
+ database_id,
+ name,
+ `type`,
+ `status`,
+ payload
+ )
+VALUES
+ (
+ 1101,
+ 101,
+ 101,
+ 9001,
+ 10001,
+ 6004,
+ 7014,
+ 'Welcome',
+ 'bb.task.general',
+ 'PENDING_APPROVAL',
+ '{"statement":"SELECT ''Welcome Tech Lead, DBA, Developer'';"}'
+ );
+
+-- Task for Pipeline 9002 add column
+-- Task for stage 10002 "Sandbox A" to update database 7002 'sandboxdb1'
+INSERT INTO
+ task (
+ id,
+ creator_id,
+ updater_id,
+ pipeline_id,
+ stage_id,
+ instance_id,
+ database_id,
+ name,
+ `type`,
+ `status`,
+ payload
+ )
+VALUES
+ (
+ 1102,
+ 103,
+ 103,
+ 9002,
+ 10002,
+ 6001,
+ 7002,
+ 'Update sandboxdb1',
+ 'bb.task.database.schema.update',
+ 'PENDING',
+ '{"statement":"ALTER TABLE sandboxdb1.warehouse ADD COLUMN location VARCHAR(255);", "rollbackStatement":"ALTER TABLE sandboxdb1.warehouse DROP COLUMN location;"}'
+ );
+
+-- Task for stage 10003 "Integration" to update database 7006 'integrationdb1'
+INSERT INTO
+ task (
+ id,
+ creator_id,
+ updater_id,
+ pipeline_id,
+ stage_id,
+ instance_id,
+ database_id,
+ name,
+ `type`,
+ `status`,
+ payload
+ )
+VALUES
+ (
+ 1103,
+ 103,
+ 103,
+ 9002,
+ 10003,
+ 6001,
+ 7006,
+ 'Update integrationdb1',
+ 'bb.task.database.schema.update',
+ 'PENDING',
+ '{"statement":"ALTER TABLE integrationdb1.warehouse ADD COLUMN location VARCHAR(255);", "rollbackStatement":"ALTER TABLE integrationdb1.warehouse DROP COLUMN location;"}'
+ );
+
+-- Task for stage 10004 "Staging" to update database 7010 'stagingdb1'
+INSERT INTO
+ task (
+ id,
+ creator_id,
+ updater_id,
+ pipeline_id,
+ stage_id,
+ instance_id,
+ database_id,
+ name,
+ `type`,
+ `status`,
+ payload
+ )
+VALUES
+ (
+ 1104,
+ 103,
+ 103,
+ 9002,
+ 10004,
+ 6003,
+ 7010,
+ 'Update stagingdb1',
+ 'bb.task.database.schema.update',
+ 'PENDING_APPROVAL',
+ '{"statement":"ALTER TABLE stagingdb1.warehouse ADD COLUMN location VARCHAR(255);", "rollbackStatement":"ALTER TABLE stagingdb1.warehouse DROP COLUMN location;"}'
+ );
+
+-- Task for stage 10005 "Prod" to update database 7014 'proddb1'
+INSERT INTO
+ task (
+ id,
+ creator_id,
+ updater_id,
+ pipeline_id,
+ stage_id,
+ instance_id,
+ database_id,
+ name,
+ `type`,
+ `status`,
+ payload
+ )
+VALUES
+ (
+ 11005,
+ 103,
+ 103,
+ 9002,
+ 10005,
+ 6004,
+ 7014,
+ 'Update proddb1',
+ 'bb.task.database.schema.update',
+ 'PENDING_APPROVAL',
+ '{"statement":"ALTER TABLE proddb1.warehouse ADD COLUMN location VARCHAR(255);", "rollbackStatement":"ALTER TABLE proddb1.warehouse DROP COLUMN location;"}'
+ );
+
+-- Task for Pipeline 9003 create table
+-- Task for stage 10006 "Sandbox A" to craete table in database 7002 'sandboxdb1'
+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 sandboxdb1',
+ 'bb.task.database.schema.update',
+ 'PENDING_APPROVAL',
+ '{"statement":"CREATE TABLE sandboxdb1.tbl1 (name TEXT);", "rollbackStatement":"DROP TABLE sandboxdb1.tbl1;"}'
+ );
+
+-- Task for stage 10003 "Integration" to update database 7006 'integrationdb1'
+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 integrationdb1',
+ 'bb.task.database.schema.update',
+ 'PENDING',
+ '{"statement":"CREATE TABLE integrationdb1.tbl1 (name TEXT);", "rollbackStatement":"DROP TABLE integrationdb1.tbl1;"}'
+ );
+
+-- Task for stage 10008 "Staging" to update database 7010 'stagingdb1' to simulate webhook push event
+INSERT INTO
+ task (
+ id,
+ creator_id,
+ updater_id,
+ pipeline_id,
+ stage_id,
+ instance_id,
+ database_id,
+ name,
+ `type`,
+ `status`,
+ payload
+ )
+VALUES
+ (
+ 11008,
+ 1,
+ 1,
+ 9004,
+ 10008,
+ 6003,
+ 7010,
+ 'create todo table',
+ 'bb.task.database.schema.update',
+ 'PENDING',
+ '{"statement":"CREATE TABLE todo (\n id INTEGER PRIMARY KEY AUTO_INCREMENT,\n title TEXT\n)\n","pushEvent":{"vcsType":"GITLAB_SELF_HOST","ref":"refs/heads/master","repoId":"7","repoUrl":"http://gitlab.bytebase.com/bytebase-test/project1","repoFullPath":"bytebase-test/project1","authorName":"tianzhou","fileCommit":{"id":"e3b3f33a455a7e3cd999b44fa9cb8ddb633e1d29","title":"Create todo table to staging db1","message":"Create todo table to staging db1","createdTs":1624006500,"url":"http://gitlab.bytebase.com/bytebase-test/project1/-/commit/e3b3f33a455a7e3cd999b44fa9cb8ddb633e1d29","authorName":"tianzhou","added":"bytebase/20210618164921_stagingdb1_create_todo_table.sql"}}}'
+ );
\ No newline at end of file
diff --git a/backend/store/seed/demo/0120_task_run.sql b/backend/store/seed/demo/0120_task_run.sql
new file mode 100644
index 0000000000..47f84bb980
--- /dev/null
+++ b/backend/store/seed/demo/0120_task_run.sql
@@ -0,0 +1,23 @@
+-- Failed task run for task 11006 create table
+INSERT INTO
+ task_run (
+ id,
+ creator_id,
+ updater_id,
+ task_id,
+ name,
+ `status`,
+ `type`,
+ error
+ )
+VALUES
+ (
+ 12001,
+ 101,
+ 101,
+ 11006,
+ 'UPDATE testdb1 task run',
+ 'FAILED',
+ 'bb.task.database.schema.update',
+ 'fake execution error'
+ );
\ No newline at end of file
diff --git a/backend/store/seed/demo/0130_issue.sql b/backend/store/seed/demo/0130_issue.sql
new file mode 100644
index 0000000000..af4b5967a1
--- /dev/null
+++ b/backend/store/seed/demo/0130_issue.sql
@@ -0,0 +1,119 @@
+-- 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,
+ subscriber_id_list
+ )
+VALUES
+ (
+ 13001,
+ 102,
+ 102,
+ 3001,
+ 9001,
+ 'Hello world!',
+ 'OPEN',
+ 'bb.issue.general',
+ 'Welcome to Bytebase, this is the issue interface where tech leads, developers and DBAs collaborate on database management issues such as: ' || char(10, 10) || ' - Requesting a new database' || char(10) || ' - Creating a table' || char(10) || ' - Creating an index' || char(10) || ' - Adding a column' || char(10) || ' - Troubleshooting performance issue' || char(10, 10) || 'Let''s bookmark this issue by clicking the star icon on the top of this page.' || char(10, 10) || 'And then click the ''Approve'' button on the top right.',
+ 101,
+ '101,102,103,104'
+ );
+
+-- Issue for the multi stage add column pipeline
+INSERT INTO
+ issue (
+ id,
+ creator_id,
+ updater_id,
+ project_id,
+ pipeline_id,
+ name,
+ `status`,
+ `type`,
+ description,
+ assignee_id,
+ subscriber_id_list
+ )
+VALUES
+ (
+ 13002,
+ 103,
+ 103,
+ 3001,
+ 9002,
+ 'Add column ''location'' to table ''warehouse''',
+ 'OPEN',
+ 'bb.issue.database.schema.update',
+ 'Add the location column to record the warehouse address.',
+ 101,
+ '101,102,103,104'
+ );
+
+-- Issue for the multi stage create table pipeline
+INSERT INTO
+ issue (
+ id,
+ creator_id,
+ updater_id,
+ project_id,
+ pipeline_id,
+ name,
+ `status`,
+ `type`,
+ description,
+ assignee_id,
+ subscriber_id_list
+ )
+VALUES
+ (
+ 13003,
+ 103,
+ 103,
+ 3002,
+ 9003,
+ 'Create a new table ''tbl1''',
+ 'OPEN',
+ 'bb.issue.database.schema.update',
+ 'Create tbl1.',
+ 101,
+ '101,102,103,104'
+ );
+
+-- Issue for simulating webhook push event
+INSERT INTO
+ issue (
+ id,
+ creator_id,
+ updater_id,
+ project_id,
+ pipeline_id,
+ name,
+ `status`,
+ `type`,
+ description,
+ assignee_id,
+ subscriber_id_list
+ )
+VALUES
+ (
+ 13004,
+ 1,
+ 1,
+ 3001,
+ 9004,
+ 'Create todo table to stagingdb1',
+ 'OPEN',
+ 'bb.issue.database.schema.update',
+ 'Create todo table to stagingdb1',
+ 1,
+ ''
+ );
\ No newline at end of file
diff --git a/backend/store/seed/demo/0140_activity.sql b/backend/store/seed/demo/0140_activity.sql
new file mode 100644
index 0000000000..d12abb4f8d
--- /dev/null
+++ b/backend/store/seed/demo/0140_activity.sql
@@ -0,0 +1,110 @@
+-- Activity for issue 13001
+INSERT INTO
+ activity (
+ id,
+ creator_id,
+ updater_id,
+ container_id,
+ `type`
+ )
+VALUES
+ (
+ 14001,
+ 1,
+ 1,
+ 13001,
+ 'bb.issue.create'
+ );
+
+INSERT INTO
+ activity (
+ id,
+ creator_id,
+ updater_id,
+ container_id,
+ `type`,
+ `comment`
+ )
+VALUES
+ (
+ 14002,
+ 101,
+ 101,
+ 13001,
+ 'bb.issue.comment.create',
+ 'Welcome!'
+ );
+
+INSERT INTO
+ activity (
+ id,
+ creator_id,
+ updater_id,
+ container_id,
+ `type`,
+ `comment`
+ )
+VALUES
+ (
+ 14003,
+ 102,
+ 102,
+ 13001,
+ 'bb.issue.comment.create',
+ 'Let''s rock!'
+ );
+
+INSERT INTO
+ activity (
+ id,
+ creator_id,
+ updater_id,
+ container_id,
+ `type`,
+ `comment`
+ )
+VALUES
+ (
+ 14004,
+ 103,
+ 103,
+ 13001,
+ 'bb.issue.comment.create',
+ 'Go fish!'
+ );
+
+-- Activity for issue 13002
+INSERT INTO
+ activity (
+ id,
+ creator_id,
+ updater_id,
+ container_id,
+ `type`
+ )
+VALUES
+ (
+ 14005,
+ 103,
+ 103,
+ 13002,
+ 'bb.issue.create'
+ );
+
+-- Activity for issue 13003
+INSERT INTO
+ activity (
+ id,
+ creator_id,
+ updater_id,
+ container_id,
+ `type`
+ )
+VALUES
+ (
+ 14006,
+ 103,
+ 103,
+ 13003,
+ 'bb.issue.create'
+ );
\ No newline at end of file
diff --git a/backend/store/seed/demo/0150_bookmark.sql b/backend/store/seed/demo/0150_bookmark.sql
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/backend/store/seed/demo/0160_vcs.sql b/backend/store/seed/demo/0160_vcs.sql
new file mode 100644
index 0000000000..70690cb4b1
--- /dev/null
+++ b/backend/store/seed/demo/0160_vcs.sql
@@ -0,0 +1,61 @@
+INSERT INTO
+ vcs (
+ id,
+ creator_id,
+ updater_id,
+ name,
+ `type`,
+ instance_url,
+ api_url,
+ application_id,
+ secret,
+ access_token,
+ expires_ts,
+ refresh_token
+ )
+VALUES
+ (
+ 16001,
+ 101,
+ 101,
+ 'GitLab Bytebase',
+ 'GITLAB_SELF_HOST',
+ 'http://gitlab.bytebase.com',
+ 'http://gitlab.bytebase.com/api/v4',
+ '0d1f706e68e3bf22be6712752726a3eec2a9684ec098a9695015f484165ed922',
+ '77deb508304dd73fa9b6868d319e1832889c6fc8ea087f400e6efe35d7c6dd87',
+ 'a6e1d552205a64c41afd377dedff745fd38a41733b2c780a506ad593ea42d27b',
+ 0,
+ 'e4b22027c3ef1847a898e2f8ef1e28056d286bc23bdd11a235711e434e447ab8'
+ );
+
+INSERT INTO
+ vcs (
+ id,
+ creator_id,
+ updater_id,
+ name,
+ `type`,
+ instance_url,
+ api_url,
+ application_id,
+ secret,
+ access_token,
+ expires_ts,
+ refresh_token
+ )
+VALUES
+ (
+ 16002,
+ 101,
+ 101,
+ 'GitLab Bytebase2',
+ 'GITLAB_SELF_HOST',
+ 'http://gitlab.bytebase.com',
+ 'http://gitlab.bytebase.com/api/v4',
+ '0d1f706e68e3bf22be6712752726a3eec2a9684ec098a9695015f484165ed922',
+ '77deb508304dd73fa9b6868d319e1832889c6fc8ea087f400e6efe35d7c6dd87',
+ 'a6e1d552205a64c41afd377dedff745fd38a41733b2c780a506ad593ea42d27b',
+ 0,
+ 'e4b22027c3ef1847a898e2f8ef1e28056d286bc23bdd11a235711e434e447ab8'
+ );
\ No newline at end of file
diff --git a/backend/store/seed/demo/0170_repo.sql b/backend/store/seed/demo/0170_repo.sql
new file mode 100644
index 0000000000..f733c0e1a1
--- /dev/null
+++ b/backend/store/seed/demo/0170_repo.sql
@@ -0,0 +1,36 @@
+INSERT INTO
+ repo (
+ id,
+ creator_id,
+ updater_id,
+ vcs_id,
+ project_id,
+ name,
+ full_path,
+ web_url,
+ base_directory,
+ branch_filter,
+ external_id,
+ external_webhook_id,
+ webhook_endpoint_id,
+ secret_token
+ )
+VALUES
+ (
+ 17001,
+ 101,
+ 101,
+ 16001,
+ 3001,
+ "project1",
+ "bytebase-test/project1",
+ "http://gitlab.bytebase.com/bytebase-test/project1",
+ "bytebase",
+ "master",
+ -- Refers to the bytebase-test/project1
+ "7",
+ -- Refers to the webhook in bytebase-test/project1
+ "5",
+ "8368dde4-e352-4696-9fef-26bd3af6ec40",
+ "VFN2lgKDRLWjJ25B"
+ );
\ No newline at end of file