Skip to content

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

perf: use int64 in the schema if possible, less chance to overflow (#370)

spinningbot50aef6782217
diff --git a/plugin/db/clickhouse/clickhouse_migration_schema.sql b/plugin/db/clickhouse/clickhouse_migration_schema.sql
index e16276eb2a..10c21c93a3 100644
--- a/plugin/db/clickhouse/clickhouse_migration_schema.sql
+++ b/plugin/db/clickhouse/clickhouse_migration_schema.sql
@@ -6,7 +6,7 @@ CREATE DATABASE bytebase;
-- Note, we don't create trigger to update created_ts and updated_ts because that may causes error:
-- ERROR 1419 (HY000): You do not have the SUPER privilege and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)
CREATE TABLE bytebase.migration_history (
- id INTEGER,
+ id BIGINT,
created_by TEXT NOT NULL,
created_ts BIGINT NOT NULL,
updated_by TEXT NOT NULL,
@@ -18,7 +18,7 @@ CREATE TABLE bytebase.migration_history (
-- Since bytebase also manages different application databases from an instance, it leverages this field to track each database migration history.
namespace TEXT NOT NULL,
-- Used to detect out of order migration together with 'namespace' and 'version' column.
- sequence INTEGER UNSIGNED NOT NULL,
+ sequence BIGINT UNSIGNED NOT NULL,
-- We call it engine because maybe we could load history from other migration tool.
-- Current allowed values are UI, VCS.
engine TEXT NOT NULL,
@@ -38,7 +38,7 @@ CREATE TABLE bytebase.migration_history (
-- Record the schema before migration. Though we could also fetch it from the previous migration history, it would complicate fetching logic.
-- Besides, by storing the schema_prev, we can perform consistency check to see if the migration history has any gaps.
schema_prev TEXT NOT NULL,
- execution_duration INTEGER NOT NULL,
+ execution_duration BIGINT NOT NULL,
issue_id TEXT NOT NULL,
payload TEXT NOT NULL
) ENGINE = MergeTree()
diff --git a/plugin/db/mysql/mysql_migration_schema.sql b/plugin/db/mysql/mysql_migration_schema.sql
index 46414c2b07..ee6ca0988e 100644
--- a/plugin/db/mysql/mysql_migration_schema.sql
+++ b/plugin/db/mysql/mysql_migration_schema.sql
@@ -6,7 +6,7 @@ CREATE DATABASE bytebase CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_general_ci';
-- Note, we don't create trigger to update created_ts and updated_ts because that may causes error:
-- ERROR 1419 (HY000): You do not have the SUPER privilege and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)
CREATE TABLE bytebase.migration_history (
- id INTEGER PRIMARY KEY AUTO_INCREMENT,
+ id BIGINT PRIMARY KEY AUTO_INCREMENT,
created_by TEXT NOT NULL,
created_ts BIGINT NOT NULL,
updated_by TEXT NOT NULL,
@@ -18,7 +18,7 @@ CREATE TABLE bytebase.migration_history (
-- Since bytebase also manages different application databases from an instance, it leverages this field to track each database migration history.
namespace TEXT NOT NULL,
-- Used to detect out of order migration together with 'namespace' and 'version' column.
- sequence INTEGER UNSIGNED NOT NULL,
+ sequence BIGINT UNSIGNED NOT NULL,
-- We call it engine because maybe we could load history from other migration tool.
-- Current allowed values are UI, VCS.
engine TEXT NOT NULL,
@@ -38,7 +38,7 @@ CREATE TABLE bytebase.migration_history (
-- Record the schema before migration. Though we could also fetch it from the previous migration history, it would complicate fetching logic.
-- Besides, by storing the schema_prev, we can perform consistency check to see if the migration history has any gaps.
schema_prev MEDIUMTEXT NOT NULL,
- execution_duration INTEGER NOT NULL,
+ execution_duration BIGINT NOT NULL,
issue_id TEXT NOT NULL,
payload TEXT NOT NULL
);
diff --git a/plugin/db/pg/pg_migration_schema.sql b/plugin/db/pg/pg_migration_schema.sql
index d8509fe5ba..d4fd44bee1 100644
--- a/plugin/db/pg/pg_migration_schema.sql
+++ b/plugin/db/pg/pg_migration_schema.sql
@@ -6,7 +6,7 @@
-- Note, we don't create trigger to update created_ts and updated_ts because that may causes error:
-- ERROR 1419 (HY000): You do not have the SUPER privilege and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)
CREATE TABLE migration_history (
- id SERIAL PRIMARY KEY,
+ id BIGSERIAL PRIMARY KEY,
created_by TEXT NOT NULL,
created_ts BIGINT NOT NULL,
updated_by TEXT NOT NULL,
@@ -18,7 +18,7 @@ CREATE TABLE migration_history (
-- Since bytebase also manages different application databases from an instance, it leverages this field to track each database migration history.
namespace TEXT NOT NULL,
-- Used to detect out of order migration together with 'namespace' and 'version' column.
- sequence INTEGER NOT NULL CHECK (sequence >= 0),
+ sequence BIGINT NOT NULL CHECK (sequence >= 0),
-- We call it engine because maybe we could load history from other migration tool.
-- Current allowed values are UI, VCS.
engine TEXT NOT NULL,
@@ -38,7 +38,7 @@ CREATE TABLE migration_history (
-- Record the schema before migration. Though we could also fetch it from the previous migration history, it would complicate fetching logic.
-- Besides, by storing the schema_prev, we can perform consistency check to see if the migration history has any gaps.
schema_prev TEXT NOT NULL,
- execution_duration INTEGER NOT NULL,
+ execution_duration BIGINT NOT NULL,
issue_id TEXT NOT NULL,
payload TEXT NOT NULL
);
diff --git a/plugin/db/snowflake/snowflake_migration_schema.sql b/plugin/db/snowflake/snowflake_migration_schema.sql
index 71ba7f531b..9956678362 100644
--- a/plugin/db/snowflake/snowflake_migration_schema.sql
+++ b/plugin/db/snowflake/snowflake_migration_schema.sql
@@ -6,7 +6,7 @@ CREATE DATABASE bytebase;
-- Note, we don't create trigger to update created_ts and updated_ts because that may causes error:
-- ERROR 1419 (HY000): You do not have the SUPER privilege and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)
CREATE TABLE bytebase.public.migration_history (
- id INTEGER PRIMARY KEY AUTOINCREMENT,
+ id BIGINT PRIMARY KEY AUTOINCREMENT,
created_by TEXT NOT NULL,
created_ts BIGINT NOT NULL,
updated_by TEXT NOT NULL,
@@ -18,7 +18,7 @@ CREATE TABLE bytebase.public.migration_history (
-- Since bytebase also manages different application databases from an instance, it leverages this field to track each database migration history.
namespace TEXT NOT NULL,
-- Used to detect out of order migration together with 'namespace' and 'version' column.
- sequence INTEGER NOT NULL,
+ sequence BIGINT NOT NULL,
-- We call it engine because maybe we could load history from other migration tool.
-- Current allowed values are UI, VCS.
engine TEXT NOT NULL,
@@ -38,7 +38,7 @@ CREATE TABLE bytebase.public.migration_history (
-- Record the schema before migration. Though we could also fetch it from the previous migration history, it would complicate fetching logic.
-- Besides, by storing the schema_prev, we can perform consistency check to see if the migration history has any gaps.
schema_prev TEXT NOT NULL,
- execution_duration INTEGER NOT NULL,
+ execution_duration BIGINT NOT NULL,
issue_id TEXT NOT NULL,
payload TEXT NOT NULL
);