Skip to content

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

fix: task run data (#7381)

p0ny6479c3310a79
diff --git a/backend/migrator/demo/default/10120##task_run.sql b/backend/migrator/demo/default/10120##task_run.sql
index 4d1d38fac9..b34fef349e 100644
--- a/backend/migrator/demo/default/10120##task_run.sql
+++ b/backend/migrator/demo/default/10120##task_run.sql
@@ -9,10 +9,8 @@ INSERT INTO
task_id,
name,
status,
- type,
code,
- result,
- payload
+ result
)
VALUES
(
@@ -24,10 +22,8 @@ VALUES
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","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"}}}'
+ '{"detail":"Established baseline version 202106280000 for database ''shop''","migrationId":1,"version":"202106280000"}'
);
-- Task run for task 11003
@@ -41,10 +37,8 @@ INSERT INTO
task_id,
name,
status,
- type,
code,
- result,
- payload
+ result
)
VALUES
(
@@ -56,10 +50,8 @@ VALUES
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","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"}}}'
+ '{"detail":"Established baseline version 202106280000 for database ''shop''","migrationId":1,"version":"202106280000"}'
);
-- Failed task run for task 11006 create table
@@ -71,7 +63,6 @@ INSERT INTO
task_id,
name,
status,
- type,
code,
result
)
@@ -83,7 +74,6 @@ VALUES
11006,
'Update testdb_dev task run',
'FAILED',
- 'bb.task.database.schema.update',
103,
'{"detail":"table \"tbl1\" already exists"}'
);
@@ -99,10 +89,8 @@ INSERT INTO
task_id,
name,
status,
- type,
code,
- result,
- payload
+ result
)
VALUES
(
@@ -114,10 +102,8 @@ VALUES
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","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"}}}'
+ '{"detail":"Established baseline version 202106280000 for database ''blog''","migrationId":1,"version":"202106280000"}'
);
-- Task run for task 11009
@@ -131,10 +117,8 @@ INSERT INTO
task_id,
name,
status,
- type,
code,
- result,
- payload
+ result
)
VALUES
(
@@ -146,10 +130,8 @@ VALUES
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","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"}}}'
+ '{"detail":"Established baseline version 202106280000 for database ''blog''","migrationId":1,"version":"202106280000"}'
);
-- Task run for task 11010
@@ -163,10 +145,8 @@ INSERT INTO
task_id,
name,
status,
- type,
code,
- result,
- payload
+ result
)
VALUES
(
@@ -178,10 +158,8 @@ VALUES
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","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"}}}'
+ '{"detail":"Established baseline version 202106280000 for database ''blog''","migrationId":1,"version":"202106280000"}'
);
-- Task run for task 11011
@@ -195,10 +173,8 @@ INSERT INTO
task_id,
name,
status,
- type,
code,
- result,
- payload
+ result
)
VALUES
(
@@ -210,10 +186,8 @@ VALUES
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","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"}}}'
+ '{"detail":"Established baseline version 202106280000 for database ''blog''","migrationId":1,"version":"202106280000"}'
);
-- Failed task run for task 11012 create table
@@ -227,10 +201,8 @@ INSERT INTO
task_id,
name,
status,
- type,
code,
- result,
- payload
+ result
)
VALUES
(
@@ -242,10 +214,8 @@ VALUES
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","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"}}}'
+ '{"detail":"database ''blog'' has already applied version 202106280100"}'
);
-- Successful task run for task 10013 create table
@@ -259,10 +229,8 @@ INSERT INTO
task_id,
name,
status,
- type,
code,
- result,
- payload
+ result
)
VALUES
(
@@ -274,10 +242,8 @@ VALUES
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)"}'
+ '{"detail":"Applied migration version 20210830011437.11013 to database \"testdb_dev\"","migrationId":1,"version":"20210830011437.11013"}'
);
-- Successful task run for task 10014 create table
@@ -291,9 +257,7 @@ INSERT INTO
task_id,
name,
status,
- type,
- result,
- payload
+ result
)
VALUES
(
@@ -305,9 +269,7 @@ VALUES
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)"}'
+ '{"detail":"Applied migration version 20210830011437.11014 to database \"testdb_integration\"","migrationId":1,"version":"20210830011437.11014"}'
);
-- Failed task run for task 10015 create table
@@ -321,10 +283,8 @@ INSERT INTO
task_id,
name,
status,
- type,
code,
- result,
- payload
+ result
)
VALUES
(
@@ -336,10 +296,8 @@ VALUES
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)"}'
+ '{"detail":"table \"tbl2\" already exists"}'
);
ALTER SEQUENCE task_run_id_seq RESTART WITH 12012;
diff --git a/backend/migrator/demo/schema-migration-history/10001##data.sql b/backend/migrator/demo/schema-migration-history/10001##data.sql
index 4be202e6b4..d1c1538a5f 100644
--- a/backend/migrator/demo/schema-migration-history/10001##data.sql
+++ b/backend/migrator/demo/schema-migration-history/10001##data.sql
@@ -120,12 +120,12 @@ INSERT INTO "public"."task" ("id", "row_status", "creator_id", "created_ts", "up
(104, 'NORMAL', 101, 1657272927, 1, 1657272938, 103, 104, 102, 103, 'Update "employee" schema', 'DONE', 'bb.task.database.schema.update', '{"statement": "Alter table\n employee\nadd\n column (\n EduBackgrounds varchar(50) not null,\n Email varchar(40) not null,\n PhoneNo varchar(15) not null,\n Credentials_type char(4) not null,\n Credentials_No varchar(10) not null,\n Manager varchar(14),\n Emergency_name varchar(16) not null,\n Emergency_phoneNo varchar(15) not null,\n Address varchar(60) not null\n )", "migrationType": "MIGRATE", "schemaVersion": "20220708093526"}', 0),
(105, 'NORMAL', 101, 1657273475, 1, 1657273487, 104, 105, 102, 103, 'Update "employee" schema', 'DONE', 'bb.task.database.schema.update', '{"statement": "alter table\n employee drop column Address;", "migrationType": "MIGRATE", "schemaVersion": "20220708094434"}', 0);
-INSERT INTO "public"."task_run" ("id", "creator_id", "created_ts", "updater_id", "updated_ts", "task_id", "name", "status", "type", "code", "comment", "result", "payload") VALUES
-(101, 1, 1657272778, 1, 1657272778, 101, 'Welcome', 'FAILED', 'bb.task.general', 0, '', '{"detail": "Something is not right..."}', '{}'),
-(102, 1, 1657272778, 1, 1657272778, 101, 'Welcome', 'RUNNING', 'bb.task.general', 0, 'Let''s give another try', '{}', '{}'),
-(103, 1, 1657272893, 1, 1657272902, 103, 'Establish "employee" baseline 1657272892', 'DONE', 'bb.task.database.schema.update', 0, '', '{"detail": "Established baseline version 20220708093449 for database \"employee\".", "version": "20220708093449", "migrationId": 1}', '{"statement": "/* Establish baseline using current schema */", "migrationType": "BASELINE", "schemaVersion": "20220708093449"}'),
-(104, 1, 1657272929, 1, 1657272938, 104, 'Update "employee" schema 1657272928', 'DONE', 'bb.task.database.schema.update', 0, '', '{"detail": "Applied migration version 20220708093526 to database \"employee\".", "version": "20220708093526", "migrationId": 2}', '{"statement": "Alter table\n employee\nadd\n column (\n EduBackgrounds varchar(50) not null,\n Email varchar(40) not null,\n PhoneNo varchar(15) not null,\n Credentials_type char(4) not null,\n Credentials_No varchar(10) not null,\n Manager varchar(14),\n Emergency_name varchar(16) not null,\n Emergency_phoneNo varchar(15) not null,\n Address varchar(60) not null\n )", "migrationType": "MIGRATE", "schemaVersion": "20220708093526"}'),
-(105, 1, 1657273477, 1, 1657273487, 105, 'Update "employee" schema 1657273476', 'DONE', 'bb.task.database.schema.update', 0, '', '{"detail": "Applied migration version 20220708094434 to database \"employee\".", "version": "20220708094434", "migrationId": 3}', '{"statement": "alter table\n employee drop column Address;", "migrationType": "MIGRATE", "schemaVersion": "20220708094434"}');
+INSERT INTO "public"."task_run" ("id", "creator_id", "created_ts", "updater_id", "updated_ts", "task_id", "name", "status", "code", "result") VALUES
+(101, 1, 1657272778, 1, 1657272778, 101, 'Welcome', 'FAILED', 0, '{"detail": "Something is not right..."}'),
+(102, 1, 1657272778, 1, 1657272778, 101, 'Welcome', 'RUNNING', 0, '{}'),
+(103, 1, 1657272893, 1, 1657272902, 103, 'Establish "employee" baseline 1657272892', 'DONE', 0, '{"detail": "Established baseline version 20220708093449 for database \"employee\".", "version": "20220708093449", "migrationId": 1}'),
+(104, 1, 1657272929, 1, 1657272938, 104, 'Update "employee" schema 1657272928', 'DONE', 0, '{"detail": "Applied migration version 20220708093526 to database \"employee\".", "version": "20220708093526", "migrationId": 2}'),
+(105, 1, 1657273477, 1, 1657273487, 105, 'Update "employee" schema 1657273476', 'DONE', 0, '{"detail": "Applied migration version 20220708094434 to database \"employee\".", "version": "20220708094434", "migrationId": 3}');
INSERT INTO "public"."task_check_run" ("id", "creator_id", "created_ts", "updater_id", "updated_ts", "task_id", "status", "type", "code", "comment", "result", "payload") VALUES
(101, 1, 1657272890, 1, 1657272892, 103, 'DONE', 'bb.task-check.database.connect', 0, '', '{"resultList": [{"title": "OK", "status": "SUCCESS", "content": "Successfully connected \"employee\""}]}', '{}'),