Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: timestamp tmp tables (#15316)
p0ny2fec9f77649a
diff --git a/backend/component/ghost/config.go b/backend/component/ghost/config.goindex 961fb3b1eb..464215579c 100644--- a/backend/component/ghost/config.go+++ b/backend/component/ghost/config.go@@ -32,21 +32,21 @@ var defaultConfig = struct {throttleHTTPIntervalMillis int64throttleHTTPTimeoutMillis int64}{- attemptInstantDDL: true, // attempt-instant-ddl- allowedRunningOnMaster: true, // allow-on-master- concurrentCountTableRows: true, // concurrent-rowcount- timestampOldTable: true, // doesn't have a gh-ost cli flag counterpart- hooksStatusIntervalSec: 60, // hooks-status-interval- heartbeatIntervalMilliseconds: 100, // heartbeat-interval-millis- niceRatio: 0, // nice-ratio- chunkSize: 1000, // chunk-size- dmlBatchSize: 10, // dml-batch-size- maxLagMillisecondsThrottleThreshold: 1500, // max-lag-millis- defaultNumRetries: 60, // default-retries- cutoverLockTimeoutSeconds: 10, // cut-over-lock-timeout-seconds- exponentialBackoffMaxInterval: 64, // exponential-backoff-max-interval- throttleHTTPIntervalMillis: 100, // throttle-http-interval-millis- throttleHTTPTimeoutMillis: 1000, // throttle-http-timeout-millis+ attemptInstantDDL: true, // attempt-instant-ddl+ allowedRunningOnMaster: true, // allow-on-master+ concurrentCountTableRows: true, // concurrent-rowcount+ timestampOldTable: false, // doesn't have a gh-ost cli flag counterpart+ hooksStatusIntervalSec: 60, // hooks-status-interval+ heartbeatIntervalMilliseconds: 100, // heartbeat-interval-millis+ niceRatio: 0, // nice-ratio+ chunkSize: 1000, // chunk-size+ dmlBatchSize: 10, // dml-batch-size+ maxLagMillisecondsThrottleThreshold: 1500, // max-lag-millis+ defaultNumRetries: 60, // default-retries+ cutoverLockTimeoutSeconds: 10, // cut-over-lock-timeout-seconds+ exponentialBackoffMaxInterval: 64, // exponential-backoff-max-interval+ throttleHTTPIntervalMillis: 100, // throttle-http-interval-millis+ throttleHTTPTimeoutMillis: 1000, // throttle-http-timeout-millis}type UserFlags struct {diff --git a/backend/runner/taskrun/schema_update_ghost_executor.go b/backend/runner/taskrun/schema_update_ghost_executor.goindex b59f73c68e..d62bb5dfcf 100644--- a/backend/runner/taskrun/schema_update_ghost_executor.go+++ b/backend/runner/taskrun/schema_update_ghost_executor.go@@ -2,6 +2,7 @@ package taskrunimport ("context"+ "fmt""log/slog""strings""time"@@ -94,7 +95,7 @@ func (exec *SchemaUpdateGhostExecutor) RunOnce(ctx context.Context, driverCtx coreturn common.Errorf(common.Internal, "admin data source not found for instance %s", instance.ResourceID)}- migrationContext, err := ghost.NewMigrationContext(ctx, task.ID, database, adminDataSource, exec.secret, tableName, "", execStatement, false, flags, 10000000)+ migrationContext, err := ghost.NewMigrationContext(ctx, task.ID, database, adminDataSource, exec.secret, tableName, fmt.Sprintf("_%d", time.Now().Unix()), execStatement, false, flags, 10000000)if err != nil {return errors.Wrap(err, "failed to init migrationContext for gh-ost")}diff --git a/backend/tests/ghost_test.go b/backend/tests/ghost_test.goindex 56e4e03b7a..35ff5f9c66 100644--- a/backend/tests/ghost_test.go+++ b/backend/tests/ghost_test.go@@ -1,5 +1,3 @@-//go:build mysql-package testsimport (diff --git a/backend/tests/sql_review_test.go b/backend/tests/sql_review_test.goindex 26c53aeada..84912c95b6 100644--- a/backend/tests/sql_review_test.go+++ b/backend/tests/sql_review_test.go@@ -1,5 +1,3 @@-//go:build mysql-package testsimport (diff --git a/backend/tests/test-data/sql_review_pg.yaml b/backend/tests/test-data/sql_review_pg.yamlindex 4ed60638fa..5b7516954a 100644--- a/backend/tests/test-data/sql_review_pg.yaml+++ b/backend/tests/test-data/sql_review_pg.yaml@@ -14,20 +14,23 @@result:- |-{- "status": "SUCCESS",- "title": "OK"+ "status": "SUCCESS",+ "title": "OK"}run: false- statement: CREATE TABLE user(id);result:- |-{- "status": "ERROR",- "title": "Syntax error",- "content": "syntax error at or near \"user\"",- "code": 201,- "sqlReviewReport": {- "startPosition": {}+ "status": "ERROR",+ "title": "Syntax error",+ "content": "syntax error at or near \"user\"",+ "code": 201,+ "sqlReviewReport": {+ "line": 1,+ "startPosition": {+ "line": 1+ }}}run: false@@ -43,131 +46,131 @@result:- |-{- "status": "ERROR",- "title": "table.require-pk",- "content": "Table \"public\".\"userTable\" requires PRIMARY KEY, related statement: \"CREATE TABLE \\\"userTable\\\"(\\n id INT,\\n name VARCHAR(255),\\n \\\"roomId\\\" INT,\\n CONSTRAINT uk1 UNIQUE (id, name),\\n CONSTRAINT fk1 FOREIGN KEY (\\\"roomId\\\") REFERENCES room(id)\\n );\"",- "code": 601,- "sqlReviewReport": {- "line": 7,- "startPosition": {- "line": 7+ "status": "ERROR",+ "title": "table.require-pk",+ "content": "Table \"public\".\"userTable\" requires PRIMARY KEY, related statement: \"CREATE TABLE \\\"userTable\\\"(\\n id INT,\\n name VARCHAR(255),\\n \\\"roomId\\\" INT,\\n CONSTRAINT uk1 UNIQUE (id, name),\\n CONSTRAINT fk1 FOREIGN KEY (\\\"roomId\\\") REFERENCES room(id)\\n );\"",+ "code": 601,+ "sqlReviewReport": {+ "line": 7,+ "startPosition": {+ "line": 7}}}- |-{- "status": "ERROR",- "title": "table.no-foreign-key",- "content": "Foreign key is not allowed in the table \"public\".\"userTable\", related statement: \"CREATE TABLE \"userTable\"(\n id INT,\n name VARCHAR(255),\n \"roomId\" INT,\n CONSTRAINT uk1 UNIQUE (id, name),\n CONSTRAINT fk1 FOREIGN KEY (\"roomId\") REFERENCES room(id)\n );\"",- "code": 602,- "sqlReviewReport": {- "line": 7,- "startPosition": {- "line": 7+ "status": "ERROR",+ "title": "table.no-foreign-key",+ "content": "Foreign key is not allowed in the table \"public\".\"userTable\", related statement: \"CREATE TABLE \"userTable\"(\n id INT,\n name VARCHAR(255),\n \"roomId\" INT,\n CONSTRAINT uk1 UNIQUE (id, name),\n CONSTRAINT fk1 FOREIGN KEY (\"roomId\") REFERENCES room(id)\n );\"",+ "code": 602,+ "sqlReviewReport": {+ "line": 7,+ "startPosition": {+ "line": 7}}}- |-{- "status": "WARNING",- "title": "naming.table",- "content": "\"userTable\" mismatches table naming convention, naming format should be \"^[a-z]+(_[a-z]+)*$\"",- "code": 301,- "sqlReviewReport": {- "line": 7,- "startPosition": {- "line": 7+ "status": "WARNING",+ "title": "naming.table",+ "content": "\"userTable\" mismatches table naming convention, naming format should be \"^[a-z]+(_[a-z]+)*$\"",+ "code": 301,+ "sqlReviewReport": {+ "line": 7,+ "startPosition": {+ "line": 7}}}- |-{- "status": "WARNING",- "title": "naming.column",- "content": "\"userTable\".\"roomId\" mismatches column naming convention, naming format should be \"^[a-z]+(_[a-z]+)*$\"",- "code": 302,- "sqlReviewReport": {- "line": 4,- "startPosition": {- "line": 4+ "status": "WARNING",+ "title": "naming.column",+ "content": "\"userTable\".\"roomId\" mismatches column naming convention, naming format should be \"^[a-z]+(_[a-z]+)*$\"",+ "code": 302,+ "sqlReviewReport": {+ "line": 4,+ "startPosition": {+ "line": 4}}}- |-{- "status": "WARNING",- "title": "naming.index.uk",- "content": "Unique key in table \"userTable\" mismatches the naming convention, expect \"^$|^uk_userTable_id_name$\" but found \"uk1\"",- "code": 304,- "sqlReviewReport": {- "line": 5,- "startPosition": {- "line": 5+ "status": "WARNING",+ "title": "naming.index.uk",+ "content": "Unique key in table \"userTable\" mismatches the naming convention, expect \"^$|^uk_userTable_id_name$\" but found \"uk1\"",+ "code": 304,+ "sqlReviewReport": {+ "line": 5,+ "startPosition": {+ "line": 5}}}- |-{- "status": "WARNING",- "title": "naming.index.fk",- "content": "Foreign key in table \"userTable\" mismatches the naming convention, expect \"^$|^fk_userTable_roomId_room_id$\" but found \"fk1\"",- "code": 305,- "sqlReviewReport": {- "line": 6,- "startPosition": {- "line": 6+ "status": "WARNING",+ "title": "naming.index.fk",+ "content": "Foreign key in table \"userTable\" mismatches the naming convention, expect \"^$|^fk_userTable_roomId_room_id$\" but found \"fk1\"",+ "code": 305,+ "sqlReviewReport": {+ "line": 6,+ "startPosition": {+ "line": 6}}}- |-{- "status": "WARNING",- "title": "column.required",- "content": "Table \"userTable\" requires columns: created_ts, creator_id, updated_ts, updater_id",- "code": 401,- "sqlReviewReport": {- "line": 7,- "startPosition": {- "line": 7+ "status": "WARNING",+ "title": "column.required",+ "content": "Table \"userTable\" requires columns: created_ts, creator_id, updated_ts, updater_id",+ "code": 401,+ "sqlReviewReport": {+ "line": 7,+ "startPosition": {+ "line": 7}}}- |-{- "status": "WARNING",- "title": "column.no-null",- "content": "Column \"id\" in \"public\".\"userTable\" cannot have NULL value",- "code": 402,- "sqlReviewReport": {- "line": 2,- "startPosition": {- "line": 2+ "status": "WARNING",+ "title": "column.no-null",+ "content": "Column \"id\" in \"public\".\"userTable\" cannot have NULL value",+ "code": 402,+ "sqlReviewReport": {+ "line": 2,+ "startPosition": {+ "line": 2}}}- |-{- "status": "WARNING",- "title": "column.no-null",- "content": "Column \"name\" in \"public\".\"userTable\" cannot have NULL value",- "code": 402,- "sqlReviewReport": {- "line": 3,- "startPosition": {- "line": 3+ "status": "WARNING",+ "title": "column.no-null",+ "content": "Column \"name\" in \"public\".\"userTable\" cannot have NULL value",+ "code": 402,+ "sqlReviewReport": {+ "line": 3,+ "startPosition": {+ "line": 3}}}- |-{- "status": "WARNING",- "title": "column.no-null",- "content": "Column \"roomId\" in \"public\".\"userTable\" cannot have NULL value",- "code": 402,- "sqlReviewReport": {- "line": 4,- "startPosition": {- "line": 4+ "status": "WARNING",+ "title": "column.no-null",+ "content": "Column \"roomId\" in \"public\".\"userTable\" cannot have NULL value",+ "code": 402,+ "sqlReviewReport": {+ "line": 4,+ "startPosition": {+ "line": 4}}}@@ -176,14 +179,14 @@result:- |-{- "status": "ERROR",- "title": "statement.where.require.update-delete",- "content": "\"DELETE FROM t\" requires WHERE clause",- "code": 202,- "sqlReviewReport": {- "line": 1,- "startPosition": {- "line": 1+ "status": "ERROR",+ "title": "statement.where.require.update-delete",+ "content": "\"DELETE FROM t\" requires WHERE clause",+ "code": 202,+ "sqlReviewReport": {+ "line": 1,+ "startPosition": {+ "line": 1}}}@@ -192,14 +195,14 @@result:- |-{- "status": "ERROR",- "title": "statement.where.no-leading-wildcard-like",- "content": "\"DELETE FROM t WHERE a like '%abc'\" uses leading wildcard LIKE",- "code": 204,- "sqlReviewReport": {- "line": 1,- "startPosition": {- "line": 1+ "status": "ERROR",+ "title": "statement.where.no-leading-wildcard-like",+ "content": "\"DELETE FROM t WHERE a like '%abc'\" uses leading wildcard LIKE",+ "code": 204,+ "sqlReviewReport": {+ "line": 1,+ "startPosition": {+ "line": 1}}}@@ -208,16 +211,16 @@result:- |-{- "status": "SUCCESS",- "title": "OK"+ "status": "SUCCESS",+ "title": "OK"}run: false- statement: INSERT INTO t VALUES (1), (2)result:- |-{- "status": "SUCCESS",- "title": "OK"+ "status": "SUCCESS",+ "title": "OK"}run: false- statement: |-@@ -233,22 +236,22 @@result:- |-{- "status": "SUCCESS",- "title": "OK"+ "status": "SUCCESS",+ "title": "OK"}run: true- statement: ALTER INDEX pk_tech_book_id RENAME TO pk1result:- |-{- "status": "WARNING",- "title": "naming.index.pk",- "content": "Primary key in table \"tech_book\" mismatches the naming convention, expect \"^$|^pk_tech_book_id$\" but found \"pk1\"",- "code": 306,- "sqlReviewReport": {- "line": 1,- "startPosition": {- "line": 1+ "status": "WARNING",+ "title": "naming.index.pk",+ "content": "Primary key in table \"tech_book\" mismatches the naming convention, expect \"^$|^pk_tech_book_id$\" but found \"pk1\"",+ "code": 306,+ "sqlReviewReport": {+ "line": 1,+ "startPosition": {+ "line": 1}}}