Skip to content

Commit

Permalink
feat: change migration history schema ENUM field to text field (byteb…
Browse files Browse the repository at this point in the history
…ase#362)

* fix(vcs): fix bug introduced during the refactor

* feat: change plan to subscription and show subscription sidebar

Will work on subscription panel in a followup PR

* feat: change migration history schema ENUM field to text field
  • Loading branch information
tianzhou committed Jan 11, 2022
1 parent 76192ea commit bbb0ac8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
9 changes: 6 additions & 3 deletions plugin/db/clickhouse/clickhouse_migration_schema.sql
Expand Up @@ -20,11 +20,14 @@ CREATE TABLE bytebase.migration_history (
-- Used to detect out of order migration together with 'namespace' and 'version' column.
sequence INTEGER UNSIGNED NOT NULL,
-- We call it engine because maybe we could load history from other migration tool.
`engine` ENUM('UI' = 0, 'VCS' = 1) NOT NULL,
`type` ENUM('BASELINE' = 0, 'MIGRATE' = 1, 'BRANCH' = 2, 'DATA' = 3) NOT NULL,
-- Current allowed values are UI, VCS.
`engine` TEXT NOT NULL,
-- Current allowed values are BASELINE, MIGRATE, BRANCH, DATA.
`type` TEXT NOT NULL,
-- Current allowed values are PENDING, DONE, FAILED.
-- MySQL runs DDL in its own transaction, so we can't record DDL and migration_history into a single transaction.
-- Thus, we create a "PENDING" record before applying the DDL and update that record to "DONE" after applying the DDL.
`status` ENUM('PENDING' = 0, 'DONE' = 1, 'FAILED' = 2) NOT NULL,
`status` TEXT NOT NULL,
-- Record the migration version.
version TEXT NOT NULL,
description TEXT NOT NULL,
Expand Down
9 changes: 6 additions & 3 deletions plugin/db/mysql/mysql_migration_schema.sql
Expand Up @@ -20,11 +20,14 @@ CREATE TABLE bytebase.migration_history (
-- Used to detect out of order migration together with 'namespace' and 'version' column.
sequence INTEGER UNSIGNED NOT NULL,
-- We call it engine because maybe we could load history from other migration tool.
`engine` ENUM('UI', 'VCS') NOT NULL,
`type` ENUM('BASELINE', 'MIGRATE', 'BRANCH', 'DATA') NOT NULL,
-- Current allowed values are UI, VCS.
`engine` TEXT NOT NULL,
-- Current allowed values are BASELINE, MIGRATE, BRANCH, DATA.
`type` TEXT NOT NULL,
-- Current allowed values are PENDING, DONE, FAILED.
-- MySQL runs DDL in its own transaction, so we can't record DDL and migration_history into a single transaction.
-- Thus, we create a "PENDING" record before applying the DDL and update that record to "DONE" after applying the DDL.
`status` ENUM('PENDING', 'DONE', 'FAILED') NOT NULL,
`status` TEXT NOT NULL,
-- Record the migration version.
version TEXT NOT NULL,
description TEXT NOT NULL,
Expand Down
9 changes: 6 additions & 3 deletions plugin/db/pg/pg_migration_schema.sql
Expand Up @@ -20,11 +20,14 @@ CREATE TABLE migration_history (
-- Used to detect out of order migration together with 'namespace' and 'version' column.
sequence INTEGER NOT NULL CHECK (sequence >= 0),
-- We call it engine because maybe we could load history from other migration tool.
engine TEXT NOT NULL CHECK (engine in ('UI', 'VCS')),
type TEXT NOT NULL CHECK (type in ('BASELINE', 'MIGRATE', 'BRANCH', 'DATA')),
-- Current allowed values are UI, VCS.
engine TEXT NOT NULL,
-- Current allowed values are BASELINE, MIGRATE, BRANCH, DATA.
type TEXT NOT NULL,
-- Current allowed values are PENDING, DONE, FAILED.
-- PostgreSQL can't do cross database transaction, so we can't record DDL and migration_history into a single transaction.
-- Thus, we create a "PENDING" record before applying the DDL and update that record to "DONE" after applying the DDL.
status TEXT NOT NULL CHECK (status in ('PENDING', 'DONE', 'FAILED')),
status TEXT NOT NULL,
-- Record the migration version.
version TEXT NOT NULL,
description TEXT NOT NULL,
Expand Down
3 changes: 3 additions & 0 deletions plugin/db/snowflake/snowflake_migration_schema.sql
Expand Up @@ -20,8 +20,11 @@ CREATE TABLE bytebase.public.migration_history (
-- Used to detect out of order migration together with 'namespace' and 'version' column.
sequence INTEGER 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,
-- Current allowed values are BASELINE, MIGRATE, BRANCH, DATA.
type TEXT NOT NULL,
-- Current allowed values are PENDING, DONE, FAILED.
-- Snowflake runs DDL in its own transaction, so we can't record DDL and migration_history into a single transaction.
-- Thus, we create a "PENDING" record before applying the DDL and update that record to "DONE" after applying the DDL.
status TEXT NOT NULL,
Expand Down

0 comments on commit bbb0ac8

Please sign in to comment.