From 0226681d3707c787f3ca6e5bfd69f36d7de473df Mon Sep 17 00:00:00 2001 From: hackerman <3372410+aeneasr@users.noreply.github.com> Date: Sun, 30 Aug 2020 14:14:23 +0200 Subject: [PATCH] Add failing test case for drop_column (#96) * Add failing test case for rename_column * Improve rename_column SQLite behavior `ALTER TABLE .. RENAME COLUMN .. TO ..` is officially supported and does not need the temporary table workaround. * Add failing test case for drop_column * Preserve foreign keys in SQLite on drop_column Closes https://github.com/gobuffalo/pop/issues/574 * Bump CockroachDB to non-EOL version CockroachDB v2.1 has reached EOL on 7/1/20. The next version v19.1 already reached maintenance support and will reach EOL in 11/1/20 which is why this was bumped to v19.2 right away. * Resolve missing keys and broken NULL constraints Resolves an issue where CockroachDB would be missing e.g. UNIQUE indices when using `change_column`. Also fixes a bug when using `change_column` with `NOT NUL` but without `DEFAULT`. * Add missing PostgreSQL E2E fixtures * Add missing MySQL E2E fixtures --- docker-compose.yml | 2 +- go.sum | 1 + internal/e2e/fixtures/cockroach/down/1.sql | 3 +- internal/e2e/fixtures/cockroach/down/10.sql | 30 +++++ internal/e2e/fixtures/cockroach/down/2.sql | 9 +- internal/e2e/fixtures/cockroach/down/3.sql | 9 +- internal/e2e/fixtures/cockroach/down/4.sql | 9 +- internal/e2e/fixtures/cockroach/down/5.sql | 9 +- internal/e2e/fixtures/cockroach/down/6.sql | 9 +- internal/e2e/fixtures/cockroach/down/7.sql | 31 +++++ internal/e2e/fixtures/cockroach/down/8.sql | 31 +++++ internal/e2e/fixtures/cockroach/down/9.sql | 31 +++++ internal/e2e/fixtures/cockroach/up/0.sql | 3 +- internal/e2e/fixtures/cockroach/up/1.sql | 5 +- internal/e2e/fixtures/cockroach/up/10.sql | 30 +++++ internal/e2e/fixtures/cockroach/up/2.sql | 5 +- internal/e2e/fixtures/cockroach/up/3.sql | 5 +- internal/e2e/fixtures/cockroach/up/4.sql | 5 +- internal/e2e/fixtures/cockroach/up/5.sql | 5 +- internal/e2e/fixtures/cockroach/up/6.sql | 5 +- internal/e2e/fixtures/cockroach/up/7.sql | 31 +++++ internal/e2e/fixtures/cockroach/up/8.sql | 31 +++++ internal/e2e/fixtures/cockroach/up/9.sql | 30 +++++ internal/e2e/fixtures/mysql/down/1.sql | 5 +- internal/e2e/fixtures/mysql/down/10.sql | 74 ++++++++++++ internal/e2e/fixtures/mysql/down/2.sql | 7 +- internal/e2e/fixtures/mysql/down/3.sql | 7 +- internal/e2e/fixtures/mysql/down/4.sql | 7 +- internal/e2e/fixtures/mysql/down/5.sql | 7 +- internal/e2e/fixtures/mysql/down/6.sql | 7 +- internal/e2e/fixtures/mysql/down/7.sql | 75 ++++++++++++ internal/e2e/fixtures/mysql/down/8.sql | 75 ++++++++++++ internal/e2e/fixtures/mysql/down/9.sql | 75 ++++++++++++ internal/e2e/fixtures/mysql/up/0.sql | 5 +- internal/e2e/fixtures/mysql/up/1.sql | 5 +- internal/e2e/fixtures/mysql/up/10.sql | 74 ++++++++++++ internal/e2e/fixtures/mysql/up/2.sql | 5 +- internal/e2e/fixtures/mysql/up/3.sql | 5 +- internal/e2e/fixtures/mysql/up/4.sql | 5 +- internal/e2e/fixtures/mysql/up/5.sql | 5 +- internal/e2e/fixtures/mysql/up/6.sql | 5 +- internal/e2e/fixtures/mysql/up/7.sql | 75 ++++++++++++ internal/e2e/fixtures/mysql/up/8.sql | 75 ++++++++++++ internal/e2e/fixtures/mysql/up/9.sql | 74 ++++++++++++ internal/e2e/fixtures/postgres/down/1.sql | 8 +- internal/e2e/fixtures/postgres/down/10.sql | 107 +++++++++++++++++ internal/e2e/fixtures/postgres/down/2.sql | 8 +- internal/e2e/fixtures/postgres/down/3.sql | 8 +- internal/e2e/fixtures/postgres/down/4.sql | 8 +- internal/e2e/fixtures/postgres/down/5.sql | 8 +- internal/e2e/fixtures/postgres/down/6.sql | 8 +- internal/e2e/fixtures/postgres/down/7.sql | 8 +- internal/e2e/fixtures/postgres/down/8.sql | 8 +- internal/e2e/fixtures/postgres/down/9.sql | 108 ++++++++++++++++++ internal/e2e/fixtures/postgres/up/10.sql | 107 +++++++++++++++++ internal/e2e/fixtures/postgres/up/9.sql | 107 +++++++++++++++++ internal/e2e/fixtures/sqlite3/down/1.sql | 3 +- internal/e2e/fixtures/sqlite3/down/10.sql | 18 +++ internal/e2e/fixtures/sqlite3/down/2.sql | 4 +- internal/e2e/fixtures/sqlite3/down/3.sql | 4 +- internal/e2e/fixtures/sqlite3/down/4.sql | 4 +- internal/e2e/fixtures/sqlite3/down/5.sql | 4 +- internal/e2e/fixtures/sqlite3/down/6.sql | 4 +- internal/e2e/fixtures/sqlite3/down/7.sql | 4 +- internal/e2e/fixtures/sqlite3/down/8.sql | 4 +- internal/e2e/fixtures/sqlite3/down/9.sql | 18 +++ internal/e2e/fixtures/sqlite3/up/10.sql | 18 +++ internal/e2e/fixtures/sqlite3/up/5.sql | 1 + internal/e2e/fixtures/sqlite3/up/6.sql | 1 + internal/e2e/fixtures/sqlite3/up/7.sql | 1 + internal/e2e/fixtures/sqlite3/up/8.sql | 1 + internal/e2e/fixtures/sqlite3/up/9.sql | 18 +++ .../20191100000010_users_drop_name.down.fizz | 1 + .../20191100000010_users_drop_name.up.fizz | 1 + ...0000011_user_posts_change_column.down.fizz | 1 + ...100000011_user_posts_change_column.up.fizz | 1 + translators/cockroach.go | 66 ++++++++++- translators/cockroach_meta.go | 2 +- translators/sqlite.go | 82 ++++++++----- translators/sqlite_meta.go | 13 ++- translators/sqlite_meta_test.go | 15 +++ translators/sqlite_test.go | 26 +++-- 82 files changed, 1649 insertions(+), 160 deletions(-) create mode 100644 internal/e2e/fixtures/cockroach/down/10.sql create mode 100644 internal/e2e/fixtures/cockroach/down/7.sql create mode 100644 internal/e2e/fixtures/cockroach/down/8.sql create mode 100644 internal/e2e/fixtures/cockroach/down/9.sql create mode 100644 internal/e2e/fixtures/cockroach/up/10.sql create mode 100644 internal/e2e/fixtures/cockroach/up/7.sql create mode 100644 internal/e2e/fixtures/cockroach/up/8.sql create mode 100644 internal/e2e/fixtures/cockroach/up/9.sql create mode 100644 internal/e2e/fixtures/mysql/down/10.sql create mode 100644 internal/e2e/fixtures/mysql/down/7.sql create mode 100644 internal/e2e/fixtures/mysql/down/8.sql create mode 100644 internal/e2e/fixtures/mysql/down/9.sql create mode 100644 internal/e2e/fixtures/mysql/up/10.sql create mode 100644 internal/e2e/fixtures/mysql/up/7.sql create mode 100644 internal/e2e/fixtures/mysql/up/8.sql create mode 100644 internal/e2e/fixtures/mysql/up/9.sql create mode 100644 internal/e2e/fixtures/postgres/down/10.sql create mode 100644 internal/e2e/fixtures/postgres/down/9.sql create mode 100644 internal/e2e/fixtures/postgres/up/10.sql create mode 100644 internal/e2e/fixtures/postgres/up/9.sql create mode 100644 internal/e2e/fixtures/sqlite3/down/10.sql create mode 100644 internal/e2e/fixtures/sqlite3/down/9.sql create mode 100644 internal/e2e/fixtures/sqlite3/up/10.sql create mode 100644 internal/e2e/fixtures/sqlite3/up/9.sql create mode 100644 internal/e2e/migrations/20191100000010_users_drop_name.down.fizz create mode 100644 internal/e2e/migrations/20191100000010_users_drop_name.up.fizz create mode 100644 internal/e2e/migrations/20191100000011_user_posts_change_column.down.fizz create mode 100644 internal/e2e/migrations/20191100000011_user_posts_change_column.up.fizz create mode 100644 translators/sqlite_meta_test.go diff --git a/docker-compose.yml b/docker-compose.yml index cd20a296..6e491d48 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,7 +22,7 @@ services: volumes: - ./sqldumps:/docker-entrypoint-initdb.d cockroach: - image: cockroachdb/cockroach:v2.1.0 + image: cockroachdb/cockroach:v19.2.10 ports: - "26257:26257" - "8080:8080" diff --git a/go.sum b/go.sum index be85d16a..af2e2500 100644 --- a/go.sum +++ b/go.sum @@ -229,6 +229,7 @@ golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7 h1:fHDIZ2oxGnUZRN6WgWFCbYBjH9uqVPRCUVUDhs0wnbA= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200219183655-46282727080f h1:dB42wwhNuwPvh8f+5zZWNcU+F2Xs/B9wXXwvUCOH7r8= golang.org/x/net v0.0.0-20200219183655-46282727080f/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= diff --git a/internal/e2e/fixtures/cockroach/down/1.sql b/internal/e2e/fixtures/cockroach/down/1.sql index 34399249..6d7a4713 100644 --- a/internal/e2e/fixtures/cockroach/down/1.sql +++ b/internal/e2e/fixtures/cockroach/down/1.sql @@ -2,8 +2,9 @@ CREATE TABLE e2e_users ( id UUID NOT NULL, created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, + username VARCHAR(255) NULL, CONSTRAINT "primary" PRIMARY KEY (id ASC), - FAMILY "primary" (id, created_at, updated_at) + FAMILY "primary" (id, created_at, updated_at, username) ); CREATE TABLE schema_migration ( diff --git a/internal/e2e/fixtures/cockroach/down/10.sql b/internal/e2e/fixtures/cockroach/down/10.sql new file mode 100644 index 00000000..16430b0b --- /dev/null +++ b/internal/e2e/fixtures/cockroach/down/10.sql @@ -0,0 +1,30 @@ +CREATE TABLE e2e_users ( + id UUID NOT NULL, + created_at TIMESTAMP NOT NULL, + updated_at TIMESTAMP NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (id ASC), + FAMILY "primary" (id, created_at, updated_at) +); + +CREATE TABLE e2e_user_posts ( + id UUID NOT NULL, + user_id UUID NOT NULL, + content VARCHAR(255) NOT NULL DEFAULT '':::STRING, + slug VARCHAR(64) NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (id ASC), + INDEX e2e_user_notes_auto_index_e2e_user_notes_e2e_users_id_fk (user_id ASC), + INDEX e2e_user_notes_user_id_idx (user_id ASC), + UNIQUE INDEX e2e_user_notes_slug_idx (slug ASC), + FAMILY "primary" (id, user_id, content, slug) +); + +CREATE TABLE schema_migration ( + version VARCHAR(14) NOT NULL, + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); + +ALTER TABLE e2e_user_posts ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES e2e_users(id) ON DELETE CASCADE; + +-- Validate foreign key constraints. These can fail if there was unvalidated data during the dump. +ALTER TABLE e2e_user_posts VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; diff --git a/internal/e2e/fixtures/cockroach/down/2.sql b/internal/e2e/fixtures/cockroach/down/2.sql index 2650d570..25f52369 100644 --- a/internal/e2e/fixtures/cockroach/down/2.sql +++ b/internal/e2e/fixtures/cockroach/down/2.sql @@ -2,20 +2,21 @@ CREATE TABLE e2e_users ( id UUID NOT NULL, created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, + username VARCHAR(255) NULL, CONSTRAINT "primary" PRIMARY KEY (id ASC), - FAMILY "primary" (id, created_at, updated_at) + FAMILY "primary" (id, created_at, updated_at, username) ); CREATE TABLE e2e_user_notes ( id UUID NOT NULL, - notes VARCHAR(255) NULL, user_id UUID NOT NULL, + notes VARCHAR(255) NULL, title VARCHAR(64) NOT NULL DEFAULT '':::STRING, CONSTRAINT "primary" PRIMARY KEY (id ASC), INDEX e2e_user_notes_auto_index_e2e_user_notes_e2e_users_id_fk (user_id ASC), INDEX e2e_user_notes_user_id_idx (user_id ASC), INDEX e2e_user_notes_title_idx (title ASC), - FAMILY "primary" (id, notes, user_id, title) + FAMILY "primary" (id, user_id, notes, title) ); CREATE TABLE schema_migration ( @@ -24,7 +25,7 @@ CREATE TABLE schema_migration ( FAMILY "primary" (version, rowid) ); -ALTER TABLE e2e_user_notes ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES e2e_users (id) ON DELETE CASCADE; +ALTER TABLE e2e_user_notes ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES e2e_users(id) ON DELETE CASCADE; -- Validate foreign key constraints. These can fail if there was unvalidated data during the dump. ALTER TABLE e2e_user_notes VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; diff --git a/internal/e2e/fixtures/cockroach/down/3.sql b/internal/e2e/fixtures/cockroach/down/3.sql index f1acc221..07a69de4 100644 --- a/internal/e2e/fixtures/cockroach/down/3.sql +++ b/internal/e2e/fixtures/cockroach/down/3.sql @@ -2,18 +2,19 @@ CREATE TABLE e2e_users ( id UUID NOT NULL, created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, + username VARCHAR(255) NULL, CONSTRAINT "primary" PRIMARY KEY (id ASC), - FAMILY "primary" (id, created_at, updated_at) + FAMILY "primary" (id, created_at, updated_at, username) ); CREATE TABLE e2e_user_notes ( id UUID NOT NULL, - notes VARCHAR(255) NULL, user_id UUID NOT NULL, + notes VARCHAR(255) NULL, CONSTRAINT "primary" PRIMARY KEY (id ASC), INDEX e2e_user_notes_auto_index_e2e_user_notes_e2e_users_id_fk (user_id ASC), INDEX e2e_user_notes_user_id_idx (user_id ASC), - FAMILY "primary" (id, notes, user_id) + FAMILY "primary" (id, user_id, notes) ); CREATE TABLE schema_migration ( @@ -22,7 +23,7 @@ CREATE TABLE schema_migration ( FAMILY "primary" (version, rowid) ); -ALTER TABLE e2e_user_notes ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES e2e_users (id) ON DELETE CASCADE; +ALTER TABLE e2e_user_notes ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES e2e_users(id) ON DELETE CASCADE; -- Validate foreign key constraints. These can fail if there was unvalidated data during the dump. ALTER TABLE e2e_user_notes VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; diff --git a/internal/e2e/fixtures/cockroach/down/4.sql b/internal/e2e/fixtures/cockroach/down/4.sql index cbee1d77..3cd32657 100644 --- a/internal/e2e/fixtures/cockroach/down/4.sql +++ b/internal/e2e/fixtures/cockroach/down/4.sql @@ -2,20 +2,21 @@ CREATE TABLE e2e_users ( id UUID NOT NULL, created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, + username VARCHAR(255) NULL, CONSTRAINT "primary" PRIMARY KEY (id ASC), - FAMILY "primary" (id, created_at, updated_at) + FAMILY "primary" (id, created_at, updated_at, username) ); CREATE TABLE e2e_user_notes ( id UUID NOT NULL, - notes VARCHAR(255) NULL, user_id UUID NOT NULL, slug VARCHAR(64) NOT NULL, + notes VARCHAR(255) NULL, CONSTRAINT "primary" PRIMARY KEY (id ASC), INDEX e2e_user_notes_auto_index_e2e_user_notes_e2e_users_id_fk (user_id ASC), INDEX e2e_user_notes_user_id_idx (user_id ASC), UNIQUE INDEX e2e_user_notes_slug_idx (slug ASC), - FAMILY "primary" (id, notes, user_id, slug) + FAMILY "primary" (id, user_id, slug, notes) ); CREATE TABLE schema_migration ( @@ -24,7 +25,7 @@ CREATE TABLE schema_migration ( FAMILY "primary" (version, rowid) ); -ALTER TABLE e2e_user_notes ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES e2e_users (id) ON DELETE CASCADE; +ALTER TABLE e2e_user_notes ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES e2e_users(id) ON DELETE CASCADE; -- Validate foreign key constraints. These can fail if there was unvalidated data during the dump. ALTER TABLE e2e_user_notes VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; diff --git a/internal/e2e/fixtures/cockroach/down/5.sql b/internal/e2e/fixtures/cockroach/down/5.sql index cbee1d77..3cd32657 100644 --- a/internal/e2e/fixtures/cockroach/down/5.sql +++ b/internal/e2e/fixtures/cockroach/down/5.sql @@ -2,20 +2,21 @@ CREATE TABLE e2e_users ( id UUID NOT NULL, created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, + username VARCHAR(255) NULL, CONSTRAINT "primary" PRIMARY KEY (id ASC), - FAMILY "primary" (id, created_at, updated_at) + FAMILY "primary" (id, created_at, updated_at, username) ); CREATE TABLE e2e_user_notes ( id UUID NOT NULL, - notes VARCHAR(255) NULL, user_id UUID NOT NULL, slug VARCHAR(64) NOT NULL, + notes VARCHAR(255) NULL, CONSTRAINT "primary" PRIMARY KEY (id ASC), INDEX e2e_user_notes_auto_index_e2e_user_notes_e2e_users_id_fk (user_id ASC), INDEX e2e_user_notes_user_id_idx (user_id ASC), UNIQUE INDEX e2e_user_notes_slug_idx (slug ASC), - FAMILY "primary" (id, notes, user_id, slug) + FAMILY "primary" (id, user_id, slug, notes) ); CREATE TABLE schema_migration ( @@ -24,7 +25,7 @@ CREATE TABLE schema_migration ( FAMILY "primary" (version, rowid) ); -ALTER TABLE e2e_user_notes ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES e2e_users (id) ON DELETE CASCADE; +ALTER TABLE e2e_user_notes ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES e2e_users(id) ON DELETE CASCADE; -- Validate foreign key constraints. These can fail if there was unvalidated data during the dump. ALTER TABLE e2e_user_notes VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; diff --git a/internal/e2e/fixtures/cockroach/down/6.sql b/internal/e2e/fixtures/cockroach/down/6.sql index cbee1d77..3cd32657 100644 --- a/internal/e2e/fixtures/cockroach/down/6.sql +++ b/internal/e2e/fixtures/cockroach/down/6.sql @@ -2,20 +2,21 @@ CREATE TABLE e2e_users ( id UUID NOT NULL, created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, + username VARCHAR(255) NULL, CONSTRAINT "primary" PRIMARY KEY (id ASC), - FAMILY "primary" (id, created_at, updated_at) + FAMILY "primary" (id, created_at, updated_at, username) ); CREATE TABLE e2e_user_notes ( id UUID NOT NULL, - notes VARCHAR(255) NULL, user_id UUID NOT NULL, slug VARCHAR(64) NOT NULL, + notes VARCHAR(255) NULL, CONSTRAINT "primary" PRIMARY KEY (id ASC), INDEX e2e_user_notes_auto_index_e2e_user_notes_e2e_users_id_fk (user_id ASC), INDEX e2e_user_notes_user_id_idx (user_id ASC), UNIQUE INDEX e2e_user_notes_slug_idx (slug ASC), - FAMILY "primary" (id, notes, user_id, slug) + FAMILY "primary" (id, user_id, slug, notes) ); CREATE TABLE schema_migration ( @@ -24,7 +25,7 @@ CREATE TABLE schema_migration ( FAMILY "primary" (version, rowid) ); -ALTER TABLE e2e_user_notes ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES e2e_users (id) ON DELETE CASCADE; +ALTER TABLE e2e_user_notes ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES e2e_users(id) ON DELETE CASCADE; -- Validate foreign key constraints. These can fail if there was unvalidated data during the dump. ALTER TABLE e2e_user_notes VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; diff --git a/internal/e2e/fixtures/cockroach/down/7.sql b/internal/e2e/fixtures/cockroach/down/7.sql new file mode 100644 index 00000000..a3f547f1 --- /dev/null +++ b/internal/e2e/fixtures/cockroach/down/7.sql @@ -0,0 +1,31 @@ +CREATE TABLE e2e_users ( + id UUID NOT NULL, + created_at TIMESTAMP NOT NULL, + updated_at TIMESTAMP NOT NULL, + username VARCHAR(255) NULL, + CONSTRAINT "primary" PRIMARY KEY (id ASC), + FAMILY "primary" (id, created_at, updated_at, username) +); + +CREATE TABLE e2e_user_posts ( + id UUID NOT NULL, + user_id UUID NOT NULL, + slug VARCHAR(64) NOT NULL, + notes VARCHAR(255) NULL, + CONSTRAINT "primary" PRIMARY KEY (id ASC), + INDEX e2e_user_notes_auto_index_e2e_user_notes_e2e_users_id_fk (user_id ASC), + INDEX e2e_user_notes_user_id_idx (user_id ASC), + UNIQUE INDEX e2e_user_notes_slug_idx (slug ASC), + FAMILY "primary" (id, user_id, slug, notes) +); + +CREATE TABLE schema_migration ( + version VARCHAR(14) NOT NULL, + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); + +ALTER TABLE e2e_user_posts ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES e2e_users(id) ON DELETE CASCADE; + +-- Validate foreign key constraints. These can fail if there was unvalidated data during the dump. +ALTER TABLE e2e_user_posts VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; diff --git a/internal/e2e/fixtures/cockroach/down/8.sql b/internal/e2e/fixtures/cockroach/down/8.sql new file mode 100644 index 00000000..4f2a1f90 --- /dev/null +++ b/internal/e2e/fixtures/cockroach/down/8.sql @@ -0,0 +1,31 @@ +CREATE TABLE e2e_users ( + id UUID NOT NULL, + created_at TIMESTAMP NOT NULL, + updated_at TIMESTAMP NOT NULL, + username VARCHAR(255) NULL, + CONSTRAINT "primary" PRIMARY KEY (id ASC), + FAMILY "primary" (id, created_at, updated_at, username) +); + +CREATE TABLE e2e_user_posts ( + id UUID NOT NULL, + user_id UUID NOT NULL, + content VARCHAR(255) NOT NULL DEFAULT '':::STRING, + slug VARCHAR(64) NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (id ASC), + INDEX e2e_user_notes_auto_index_e2e_user_notes_e2e_users_id_fk (user_id ASC), + INDEX e2e_user_notes_user_id_idx (user_id ASC), + UNIQUE INDEX e2e_user_notes_slug_idx (slug ASC), + FAMILY "primary" (id, user_id, content, slug) +); + +CREATE TABLE schema_migration ( + version VARCHAR(14) NOT NULL, + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); + +ALTER TABLE e2e_user_posts ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES e2e_users(id) ON DELETE CASCADE; + +-- Validate foreign key constraints. These can fail if there was unvalidated data during the dump. +ALTER TABLE e2e_user_posts VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; diff --git a/internal/e2e/fixtures/cockroach/down/9.sql b/internal/e2e/fixtures/cockroach/down/9.sql new file mode 100644 index 00000000..2b99d53e --- /dev/null +++ b/internal/e2e/fixtures/cockroach/down/9.sql @@ -0,0 +1,31 @@ +CREATE TABLE e2e_users ( + id UUID NOT NULL, + created_at TIMESTAMP NOT NULL, + updated_at TIMESTAMP NOT NULL, + name VARCHAR(255) NULL, + CONSTRAINT "primary" PRIMARY KEY (id ASC), + FAMILY "primary" (id, created_at, updated_at, name) +); + +CREATE TABLE e2e_user_posts ( + id UUID NOT NULL, + user_id UUID NOT NULL, + content VARCHAR(255) NOT NULL DEFAULT '':::STRING, + slug VARCHAR(64) NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (id ASC), + INDEX e2e_user_notes_auto_index_e2e_user_notes_e2e_users_id_fk (user_id ASC), + INDEX e2e_user_notes_user_id_idx (user_id ASC), + UNIQUE INDEX e2e_user_notes_slug_idx (slug ASC), + FAMILY "primary" (id, user_id, content, slug) +); + +CREATE TABLE schema_migration ( + version VARCHAR(14) NOT NULL, + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); + +ALTER TABLE e2e_user_posts ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES e2e_users(id) ON DELETE CASCADE; + +-- Validate foreign key constraints. These can fail if there was unvalidated data during the dump. +ALTER TABLE e2e_user_posts VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; diff --git a/internal/e2e/fixtures/cockroach/up/0.sql b/internal/e2e/fixtures/cockroach/up/0.sql index 34399249..094f36b7 100644 --- a/internal/e2e/fixtures/cockroach/up/0.sql +++ b/internal/e2e/fixtures/cockroach/up/0.sql @@ -1,9 +1,10 @@ CREATE TABLE e2e_users ( id UUID NOT NULL, + username VARCHAR(255) NULL, created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, CONSTRAINT "primary" PRIMARY KEY (id ASC), - FAMILY "primary" (id, created_at, updated_at) + FAMILY "primary" (id, username, created_at, updated_at) ); CREATE TABLE schema_migration ( diff --git a/internal/e2e/fixtures/cockroach/up/1.sql b/internal/e2e/fixtures/cockroach/up/1.sql index feb711c1..99e6f184 100644 --- a/internal/e2e/fixtures/cockroach/up/1.sql +++ b/internal/e2e/fixtures/cockroach/up/1.sql @@ -1,9 +1,10 @@ CREATE TABLE e2e_users ( id UUID NOT NULL, + username VARCHAR(255) NULL, created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, CONSTRAINT "primary" PRIMARY KEY (id ASC), - FAMILY "primary" (id, created_at, updated_at) + FAMILY "primary" (id, username, created_at, updated_at) ); CREATE TABLE e2e_user_notes ( @@ -24,7 +25,7 @@ CREATE TABLE schema_migration ( FAMILY "primary" (version, rowid) ); -ALTER TABLE e2e_user_notes ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES e2e_users (id) ON DELETE CASCADE; +ALTER TABLE e2e_user_notes ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES e2e_users(id) ON DELETE CASCADE; -- Validate foreign key constraints. These can fail if there was unvalidated data during the dump. ALTER TABLE e2e_user_notes VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; diff --git a/internal/e2e/fixtures/cockroach/up/10.sql b/internal/e2e/fixtures/cockroach/up/10.sql new file mode 100644 index 00000000..5346f6ce --- /dev/null +++ b/internal/e2e/fixtures/cockroach/up/10.sql @@ -0,0 +1,30 @@ +CREATE TABLE e2e_users ( + id UUID NOT NULL, + created_at TIMESTAMP NOT NULL, + updated_at TIMESTAMP NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (id ASC), + FAMILY "primary" (id, created_at, updated_at) +); + +CREATE TABLE e2e_user_posts ( + id UUID NOT NULL, + user_id UUID NOT NULL, + content VARCHAR(255) NOT NULL DEFAULT '':::STRING, + slug VARCHAR(32) NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (id ASC), + INDEX e2e_user_notes_auto_index_e2e_user_notes_e2e_users_id_fk (user_id ASC), + INDEX e2e_user_notes_user_id_idx (user_id ASC), + UNIQUE INDEX e2e_user_notes_slug_idx (slug ASC), + FAMILY "primary" (id, user_id, content, slug) +); + +CREATE TABLE schema_migration ( + version VARCHAR(14) NOT NULL, + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); + +ALTER TABLE e2e_user_posts ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES e2e_users(id) ON DELETE CASCADE; + +-- Validate foreign key constraints. These can fail if there was unvalidated data during the dump. +ALTER TABLE e2e_user_posts VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; diff --git a/internal/e2e/fixtures/cockroach/up/2.sql b/internal/e2e/fixtures/cockroach/up/2.sql index f1acc221..7ac1b314 100644 --- a/internal/e2e/fixtures/cockroach/up/2.sql +++ b/internal/e2e/fixtures/cockroach/up/2.sql @@ -1,9 +1,10 @@ CREATE TABLE e2e_users ( id UUID NOT NULL, + username VARCHAR(255) NULL, created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, CONSTRAINT "primary" PRIMARY KEY (id ASC), - FAMILY "primary" (id, created_at, updated_at) + FAMILY "primary" (id, username, created_at, updated_at) ); CREATE TABLE e2e_user_notes ( @@ -22,7 +23,7 @@ CREATE TABLE schema_migration ( FAMILY "primary" (version, rowid) ); -ALTER TABLE e2e_user_notes ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES e2e_users (id) ON DELETE CASCADE; +ALTER TABLE e2e_user_notes ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES e2e_users(id) ON DELETE CASCADE; -- Validate foreign key constraints. These can fail if there was unvalidated data during the dump. ALTER TABLE e2e_user_notes VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; diff --git a/internal/e2e/fixtures/cockroach/up/3.sql b/internal/e2e/fixtures/cockroach/up/3.sql index 314f3572..e558dd85 100644 --- a/internal/e2e/fixtures/cockroach/up/3.sql +++ b/internal/e2e/fixtures/cockroach/up/3.sql @@ -1,9 +1,10 @@ CREATE TABLE e2e_users ( id UUID NOT NULL, + username VARCHAR(255) NULL, created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, CONSTRAINT "primary" PRIMARY KEY (id ASC), - FAMILY "primary" (id, created_at, updated_at) + FAMILY "primary" (id, username, created_at, updated_at) ); CREATE TABLE e2e_user_notes ( @@ -23,7 +24,7 @@ CREATE TABLE schema_migration ( FAMILY "primary" (version, rowid) ); -ALTER TABLE e2e_user_notes ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES e2e_users (id) ON DELETE CASCADE; +ALTER TABLE e2e_user_notes ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES e2e_users(id) ON DELETE CASCADE; -- Validate foreign key constraints. These can fail if there was unvalidated data during the dump. ALTER TABLE e2e_user_notes VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; diff --git a/internal/e2e/fixtures/cockroach/up/4.sql b/internal/e2e/fixtures/cockroach/up/4.sql index 314f3572..e558dd85 100644 --- a/internal/e2e/fixtures/cockroach/up/4.sql +++ b/internal/e2e/fixtures/cockroach/up/4.sql @@ -1,9 +1,10 @@ CREATE TABLE e2e_users ( id UUID NOT NULL, + username VARCHAR(255) NULL, created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, CONSTRAINT "primary" PRIMARY KEY (id ASC), - FAMILY "primary" (id, created_at, updated_at) + FAMILY "primary" (id, username, created_at, updated_at) ); CREATE TABLE e2e_user_notes ( @@ -23,7 +24,7 @@ CREATE TABLE schema_migration ( FAMILY "primary" (version, rowid) ); -ALTER TABLE e2e_user_notes ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES e2e_users (id) ON DELETE CASCADE; +ALTER TABLE e2e_user_notes ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES e2e_users(id) ON DELETE CASCADE; -- Validate foreign key constraints. These can fail if there was unvalidated data during the dump. ALTER TABLE e2e_user_notes VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; diff --git a/internal/e2e/fixtures/cockroach/up/5.sql b/internal/e2e/fixtures/cockroach/up/5.sql index cbee1d77..b66869e4 100644 --- a/internal/e2e/fixtures/cockroach/up/5.sql +++ b/internal/e2e/fixtures/cockroach/up/5.sql @@ -1,9 +1,10 @@ CREATE TABLE e2e_users ( id UUID NOT NULL, + username VARCHAR(255) NULL, created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, CONSTRAINT "primary" PRIMARY KEY (id ASC), - FAMILY "primary" (id, created_at, updated_at) + FAMILY "primary" (id, username, created_at, updated_at) ); CREATE TABLE e2e_user_notes ( @@ -24,7 +25,7 @@ CREATE TABLE schema_migration ( FAMILY "primary" (version, rowid) ); -ALTER TABLE e2e_user_notes ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES e2e_users (id) ON DELETE CASCADE; +ALTER TABLE e2e_user_notes ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES e2e_users(id) ON DELETE CASCADE; -- Validate foreign key constraints. These can fail if there was unvalidated data during the dump. ALTER TABLE e2e_user_notes VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; diff --git a/internal/e2e/fixtures/cockroach/up/6.sql b/internal/e2e/fixtures/cockroach/up/6.sql index 2a8eb5a7..6b7f10b2 100644 --- a/internal/e2e/fixtures/cockroach/up/6.sql +++ b/internal/e2e/fixtures/cockroach/up/6.sql @@ -1,9 +1,10 @@ CREATE TABLE e2e_users ( id UUID NOT NULL, + username VARCHAR(255) NULL, created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, CONSTRAINT "primary" PRIMARY KEY (id ASC), - FAMILY "primary" (id, created_at, updated_at) + FAMILY "primary" (id, username, created_at, updated_at) ); CREATE TABLE e2e_user_posts ( @@ -24,7 +25,7 @@ CREATE TABLE schema_migration ( FAMILY "primary" (version, rowid) ); -ALTER TABLE e2e_user_posts ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES e2e_users (id) ON DELETE CASCADE; +ALTER TABLE e2e_user_posts ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES e2e_users(id) ON DELETE CASCADE; -- Validate foreign key constraints. These can fail if there was unvalidated data during the dump. ALTER TABLE e2e_user_posts VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; diff --git a/internal/e2e/fixtures/cockroach/up/7.sql b/internal/e2e/fixtures/cockroach/up/7.sql new file mode 100644 index 00000000..c0843a8b --- /dev/null +++ b/internal/e2e/fixtures/cockroach/up/7.sql @@ -0,0 +1,31 @@ +CREATE TABLE e2e_users ( + id UUID NOT NULL, + username VARCHAR(255) NULL, + created_at TIMESTAMP NOT NULL, + updated_at TIMESTAMP NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (id ASC), + FAMILY "primary" (id, username, created_at, updated_at) +); + +CREATE TABLE e2e_user_posts ( + id UUID NOT NULL, + user_id UUID NOT NULL, + slug VARCHAR(64) NOT NULL, + content VARCHAR(255) NOT NULL DEFAULT '':::STRING, + CONSTRAINT "primary" PRIMARY KEY (id ASC), + INDEX e2e_user_notes_auto_index_e2e_user_notes_e2e_users_id_fk (user_id ASC), + INDEX e2e_user_notes_user_id_idx (user_id ASC), + UNIQUE INDEX e2e_user_notes_slug_idx (slug ASC), + FAMILY "primary" (id, user_id, slug, content) +); + +CREATE TABLE schema_migration ( + version VARCHAR(14) NOT NULL, + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); + +ALTER TABLE e2e_user_posts ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES e2e_users(id) ON DELETE CASCADE; + +-- Validate foreign key constraints. These can fail if there was unvalidated data during the dump. +ALTER TABLE e2e_user_posts VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; diff --git a/internal/e2e/fixtures/cockroach/up/8.sql b/internal/e2e/fixtures/cockroach/up/8.sql new file mode 100644 index 00000000..fe96793b --- /dev/null +++ b/internal/e2e/fixtures/cockroach/up/8.sql @@ -0,0 +1,31 @@ +CREATE TABLE e2e_users ( + id UUID NOT NULL, + name VARCHAR(255) NULL, + created_at TIMESTAMP NOT NULL, + updated_at TIMESTAMP NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (id ASC), + FAMILY "primary" (id, name, created_at, updated_at) +); + +CREATE TABLE e2e_user_posts ( + id UUID NOT NULL, + user_id UUID NOT NULL, + slug VARCHAR(64) NOT NULL, + content VARCHAR(255) NOT NULL DEFAULT '':::STRING, + CONSTRAINT "primary" PRIMARY KEY (id ASC), + INDEX e2e_user_notes_auto_index_e2e_user_notes_e2e_users_id_fk (user_id ASC), + INDEX e2e_user_notes_user_id_idx (user_id ASC), + UNIQUE INDEX e2e_user_notes_slug_idx (slug ASC), + FAMILY "primary" (id, user_id, slug, content) +); + +CREATE TABLE schema_migration ( + version VARCHAR(14) NOT NULL, + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); + +ALTER TABLE e2e_user_posts ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES e2e_users(id) ON DELETE CASCADE; + +-- Validate foreign key constraints. These can fail if there was unvalidated data during the dump. +ALTER TABLE e2e_user_posts VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; diff --git a/internal/e2e/fixtures/cockroach/up/9.sql b/internal/e2e/fixtures/cockroach/up/9.sql new file mode 100644 index 00000000..99fb8e71 --- /dev/null +++ b/internal/e2e/fixtures/cockroach/up/9.sql @@ -0,0 +1,30 @@ +CREATE TABLE e2e_users ( + id UUID NOT NULL, + created_at TIMESTAMP NOT NULL, + updated_at TIMESTAMP NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (id ASC), + FAMILY "primary" (id, created_at, updated_at) +); + +CREATE TABLE e2e_user_posts ( + id UUID NOT NULL, + user_id UUID NOT NULL, + slug VARCHAR(64) NOT NULL, + content VARCHAR(255) NOT NULL DEFAULT '':::STRING, + CONSTRAINT "primary" PRIMARY KEY (id ASC), + INDEX e2e_user_notes_auto_index_e2e_user_notes_e2e_users_id_fk (user_id ASC), + INDEX e2e_user_notes_user_id_idx (user_id ASC), + UNIQUE INDEX e2e_user_notes_slug_idx (slug ASC), + FAMILY "primary" (id, user_id, slug, content) +); + +CREATE TABLE schema_migration ( + version VARCHAR(14) NOT NULL, + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); + +ALTER TABLE e2e_user_posts ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES e2e_users(id) ON DELETE CASCADE; + +-- Validate foreign key constraints. These can fail if there was unvalidated data during the dump. +ALTER TABLE e2e_user_posts VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; diff --git a/internal/e2e/fixtures/mysql/down/1.sql b/internal/e2e/fixtures/mysql/down/1.sql index 1e33ff32..368461d2 100644 --- a/internal/e2e/fixtures/mysql/down/1.sql +++ b/internal/e2e/fixtures/mysql/down/1.sql @@ -2,7 +2,7 @@ -- -- Host: 127.0.0.1 Database: pop_test -- ------------------------------------------------------ --- Server version 5.7.30 +-- Server version 5.7.31 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -26,6 +26,7 @@ CREATE TABLE `e2e_users` ( `id` char(36) NOT NULL, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, + `username` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; /*!40101 SET character_set_client = @saved_cs_client */; @@ -52,4 +53,4 @@ CREATE TABLE `schema_migration` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-06-20 14:38:23 +-- Dump completed on 2020-08-27 23:39:25 diff --git a/internal/e2e/fixtures/mysql/down/10.sql b/internal/e2e/fixtures/mysql/down/10.sql new file mode 100644 index 00000000..335b6cd1 --- /dev/null +++ b/internal/e2e/fixtures/mysql/down/10.sql @@ -0,0 +1,74 @@ +-- MySQL dump 10.13 Distrib 5.7.29, for macos10.14 (x86_64) +-- +-- Host: 127.0.0.1 Database: pop_test +-- ------------------------------------------------------ +-- Server version 5.7.31 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `e2e_user_posts` +-- + +DROP TABLE IF EXISTS `e2e_user_posts`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `e2e_user_posts` ( + `id` char(36) NOT NULL, + `user_id` char(36) NOT NULL, + `slug` varchar(64) NOT NULL, + `content` varchar(255) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + UNIQUE KEY `e2e_user_notes_slug_idx` (`slug`), + KEY `e2e_user_notes_user_id_idx` (`user_id`), + CONSTRAINT `e2e_user_posts_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `e2e_users` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `e2e_users` +-- + +DROP TABLE IF EXISTS `e2e_users`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `e2e_users` ( + `id` char(36) NOT NULL, + `created_at` datetime NOT NULL, + `updated_at` datetime NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `schema_migration` +-- + +DROP TABLE IF EXISTS `schema_migration`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `schema_migration` ( + `version` varchar(14) NOT NULL, + UNIQUE KEY `schema_migration_version_idx` (`version`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2020-08-27 23:39:23 diff --git a/internal/e2e/fixtures/mysql/down/2.sql b/internal/e2e/fixtures/mysql/down/2.sql index fd646a27..998e6bcb 100644 --- a/internal/e2e/fixtures/mysql/down/2.sql +++ b/internal/e2e/fixtures/mysql/down/2.sql @@ -2,7 +2,7 @@ -- -- Host: 127.0.0.1 Database: pop_test -- ------------------------------------------------------ --- Server version 5.7.30 +-- Server version 5.7.31 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -24,8 +24,8 @@ DROP TABLE IF EXISTS `e2e_user_notes`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `e2e_user_notes` ( `id` char(36) NOT NULL, - `notes` varchar(255) DEFAULT NULL, `user_id` char(36) NOT NULL, + `notes` varchar(255) DEFAULT NULL, `title` varchar(64) NOT NULL DEFAULT '', PRIMARY KEY (`id`), KEY `e2e_user_notes_user_id_idx` (`user_id`), @@ -45,6 +45,7 @@ CREATE TABLE `e2e_users` ( `id` char(36) NOT NULL, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, + `username` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; /*!40101 SET character_set_client = @saved_cs_client */; @@ -71,4 +72,4 @@ CREATE TABLE `schema_migration` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-06-20 18:55:54 +-- Dump completed on 2020-08-27 23:39:25 diff --git a/internal/e2e/fixtures/mysql/down/3.sql b/internal/e2e/fixtures/mysql/down/3.sql index 5da1424e..dbf32248 100644 --- a/internal/e2e/fixtures/mysql/down/3.sql +++ b/internal/e2e/fixtures/mysql/down/3.sql @@ -2,7 +2,7 @@ -- -- Host: 127.0.0.1 Database: pop_test -- ------------------------------------------------------ --- Server version 5.7.30 +-- Server version 5.7.31 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -24,8 +24,8 @@ DROP TABLE IF EXISTS `e2e_user_notes`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `e2e_user_notes` ( `id` char(36) NOT NULL, - `notes` varchar(255) DEFAULT NULL, `user_id` char(36) NOT NULL, + `notes` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`), KEY `e2e_user_notes_user_id_idx` (`user_id`), CONSTRAINT `e2e_user_notes_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `e2e_users` (`id`) ON DELETE CASCADE @@ -43,6 +43,7 @@ CREATE TABLE `e2e_users` ( `id` char(36) NOT NULL, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, + `username` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; /*!40101 SET character_set_client = @saved_cs_client */; @@ -69,4 +70,4 @@ CREATE TABLE `schema_migration` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-06-20 18:55:54 +-- Dump completed on 2020-08-27 23:39:25 diff --git a/internal/e2e/fixtures/mysql/down/4.sql b/internal/e2e/fixtures/mysql/down/4.sql index e300ae3e..7e47d10d 100644 --- a/internal/e2e/fixtures/mysql/down/4.sql +++ b/internal/e2e/fixtures/mysql/down/4.sql @@ -2,7 +2,7 @@ -- -- Host: 127.0.0.1 Database: pop_test -- ------------------------------------------------------ --- Server version 5.7.30 +-- Server version 5.7.31 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -24,9 +24,9 @@ DROP TABLE IF EXISTS `e2e_user_notes`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `e2e_user_notes` ( `id` char(36) NOT NULL, - `notes` varchar(255) DEFAULT NULL, `user_id` char(36) NOT NULL, `slug` varchar(64) NOT NULL, + `notes` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `e2e_user_notes_slug_idx` (`slug`), KEY `e2e_user_notes_user_id_idx` (`user_id`), @@ -45,6 +45,7 @@ CREATE TABLE `e2e_users` ( `id` char(36) NOT NULL, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, + `username` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; /*!40101 SET character_set_client = @saved_cs_client */; @@ -71,4 +72,4 @@ CREATE TABLE `schema_migration` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-06-20 18:55:53 +-- Dump completed on 2020-08-27 23:39:24 diff --git a/internal/e2e/fixtures/mysql/down/5.sql b/internal/e2e/fixtures/mysql/down/5.sql index e300ae3e..7e47d10d 100644 --- a/internal/e2e/fixtures/mysql/down/5.sql +++ b/internal/e2e/fixtures/mysql/down/5.sql @@ -2,7 +2,7 @@ -- -- Host: 127.0.0.1 Database: pop_test -- ------------------------------------------------------ --- Server version 5.7.30 +-- Server version 5.7.31 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -24,9 +24,9 @@ DROP TABLE IF EXISTS `e2e_user_notes`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `e2e_user_notes` ( `id` char(36) NOT NULL, - `notes` varchar(255) DEFAULT NULL, `user_id` char(36) NOT NULL, `slug` varchar(64) NOT NULL, + `notes` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `e2e_user_notes_slug_idx` (`slug`), KEY `e2e_user_notes_user_id_idx` (`user_id`), @@ -45,6 +45,7 @@ CREATE TABLE `e2e_users` ( `id` char(36) NOT NULL, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, + `username` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; /*!40101 SET character_set_client = @saved_cs_client */; @@ -71,4 +72,4 @@ CREATE TABLE `schema_migration` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-06-20 18:55:53 +-- Dump completed on 2020-08-27 23:39:24 diff --git a/internal/e2e/fixtures/mysql/down/6.sql b/internal/e2e/fixtures/mysql/down/6.sql index e300ae3e..7e47d10d 100644 --- a/internal/e2e/fixtures/mysql/down/6.sql +++ b/internal/e2e/fixtures/mysql/down/6.sql @@ -2,7 +2,7 @@ -- -- Host: 127.0.0.1 Database: pop_test -- ------------------------------------------------------ --- Server version 5.7.30 +-- Server version 5.7.31 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -24,9 +24,9 @@ DROP TABLE IF EXISTS `e2e_user_notes`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `e2e_user_notes` ( `id` char(36) NOT NULL, - `notes` varchar(255) DEFAULT NULL, `user_id` char(36) NOT NULL, `slug` varchar(64) NOT NULL, + `notes` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `e2e_user_notes_slug_idx` (`slug`), KEY `e2e_user_notes_user_id_idx` (`user_id`), @@ -45,6 +45,7 @@ CREATE TABLE `e2e_users` ( `id` char(36) NOT NULL, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, + `username` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; /*!40101 SET character_set_client = @saved_cs_client */; @@ -71,4 +72,4 @@ CREATE TABLE `schema_migration` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-06-20 18:55:53 +-- Dump completed on 2020-08-27 23:39:24 diff --git a/internal/e2e/fixtures/mysql/down/7.sql b/internal/e2e/fixtures/mysql/down/7.sql new file mode 100644 index 00000000..5d979f22 --- /dev/null +++ b/internal/e2e/fixtures/mysql/down/7.sql @@ -0,0 +1,75 @@ +-- MySQL dump 10.13 Distrib 5.7.29, for macos10.14 (x86_64) +-- +-- Host: 127.0.0.1 Database: pop_test +-- ------------------------------------------------------ +-- Server version 5.7.31 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `e2e_user_posts` +-- + +DROP TABLE IF EXISTS `e2e_user_posts`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `e2e_user_posts` ( + `id` char(36) NOT NULL, + `user_id` char(36) NOT NULL, + `slug` varchar(64) NOT NULL, + `notes` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `e2e_user_notes_slug_idx` (`slug`), + KEY `e2e_user_notes_user_id_idx` (`user_id`), + CONSTRAINT `e2e_user_posts_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `e2e_users` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `e2e_users` +-- + +DROP TABLE IF EXISTS `e2e_users`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `e2e_users` ( + `id` char(36) NOT NULL, + `created_at` datetime NOT NULL, + `updated_at` datetime NOT NULL, + `username` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `schema_migration` +-- + +DROP TABLE IF EXISTS `schema_migration`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `schema_migration` ( + `version` varchar(14) NOT NULL, + UNIQUE KEY `schema_migration_version_idx` (`version`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2020-08-27 23:39:24 diff --git a/internal/e2e/fixtures/mysql/down/8.sql b/internal/e2e/fixtures/mysql/down/8.sql new file mode 100644 index 00000000..c8b762f0 --- /dev/null +++ b/internal/e2e/fixtures/mysql/down/8.sql @@ -0,0 +1,75 @@ +-- MySQL dump 10.13 Distrib 5.7.29, for macos10.14 (x86_64) +-- +-- Host: 127.0.0.1 Database: pop_test +-- ------------------------------------------------------ +-- Server version 5.7.31 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `e2e_user_posts` +-- + +DROP TABLE IF EXISTS `e2e_user_posts`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `e2e_user_posts` ( + `id` char(36) NOT NULL, + `user_id` char(36) NOT NULL, + `slug` varchar(64) NOT NULL, + `content` varchar(255) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + UNIQUE KEY `e2e_user_notes_slug_idx` (`slug`), + KEY `e2e_user_notes_user_id_idx` (`user_id`), + CONSTRAINT `e2e_user_posts_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `e2e_users` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `e2e_users` +-- + +DROP TABLE IF EXISTS `e2e_users`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `e2e_users` ( + `id` char(36) NOT NULL, + `created_at` datetime NOT NULL, + `updated_at` datetime NOT NULL, + `username` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `schema_migration` +-- + +DROP TABLE IF EXISTS `schema_migration`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `schema_migration` ( + `version` varchar(14) NOT NULL, + UNIQUE KEY `schema_migration_version_idx` (`version`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2020-08-27 23:39:24 diff --git a/internal/e2e/fixtures/mysql/down/9.sql b/internal/e2e/fixtures/mysql/down/9.sql new file mode 100644 index 00000000..a51c9c66 --- /dev/null +++ b/internal/e2e/fixtures/mysql/down/9.sql @@ -0,0 +1,75 @@ +-- MySQL dump 10.13 Distrib 5.7.29, for macos10.14 (x86_64) +-- +-- Host: 127.0.0.1 Database: pop_test +-- ------------------------------------------------------ +-- Server version 5.7.31 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `e2e_user_posts` +-- + +DROP TABLE IF EXISTS `e2e_user_posts`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `e2e_user_posts` ( + `id` char(36) NOT NULL, + `user_id` char(36) NOT NULL, + `slug` varchar(64) NOT NULL, + `content` varchar(255) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + UNIQUE KEY `e2e_user_notes_slug_idx` (`slug`), + KEY `e2e_user_notes_user_id_idx` (`user_id`), + CONSTRAINT `e2e_user_posts_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `e2e_users` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `e2e_users` +-- + +DROP TABLE IF EXISTS `e2e_users`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `e2e_users` ( + `id` char(36) NOT NULL, + `created_at` datetime NOT NULL, + `updated_at` datetime NOT NULL, + `name` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `schema_migration` +-- + +DROP TABLE IF EXISTS `schema_migration`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `schema_migration` ( + `version` varchar(14) NOT NULL, + UNIQUE KEY `schema_migration_version_idx` (`version`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2020-08-27 23:39:23 diff --git a/internal/e2e/fixtures/mysql/up/0.sql b/internal/e2e/fixtures/mysql/up/0.sql index 8f516f45..282dbeed 100644 --- a/internal/e2e/fixtures/mysql/up/0.sql +++ b/internal/e2e/fixtures/mysql/up/0.sql @@ -2,7 +2,7 @@ -- -- Host: 127.0.0.1 Database: pop_test -- ------------------------------------------------------ --- Server version 5.7.30 +-- Server version 5.7.31 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -24,6 +24,7 @@ DROP TABLE IF EXISTS `e2e_users`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `e2e_users` ( `id` char(36) NOT NULL, + `username` varchar(255) DEFAULT NULL, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, PRIMARY KEY (`id`) @@ -52,4 +53,4 @@ CREATE TABLE `schema_migration` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-06-20 14:38:22 +-- Dump completed on 2020-08-27 23:39:21 diff --git a/internal/e2e/fixtures/mysql/up/1.sql b/internal/e2e/fixtures/mysql/up/1.sql index 457e3f8a..42736eb7 100644 --- a/internal/e2e/fixtures/mysql/up/1.sql +++ b/internal/e2e/fixtures/mysql/up/1.sql @@ -2,7 +2,7 @@ -- -- Host: 127.0.0.1 Database: pop_test -- ------------------------------------------------------ --- Server version 5.7.30 +-- Server version 5.7.31 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -43,6 +43,7 @@ DROP TABLE IF EXISTS `e2e_users`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `e2e_users` ( `id` char(36) NOT NULL, + `username` varchar(255) DEFAULT NULL, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, PRIMARY KEY (`id`) @@ -71,4 +72,4 @@ CREATE TABLE `schema_migration` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-06-20 18:55:52 +-- Dump completed on 2020-08-27 23:39:21 diff --git a/internal/e2e/fixtures/mysql/up/10.sql b/internal/e2e/fixtures/mysql/up/10.sql new file mode 100644 index 00000000..5da2a4f1 --- /dev/null +++ b/internal/e2e/fixtures/mysql/up/10.sql @@ -0,0 +1,74 @@ +-- MySQL dump 10.13 Distrib 5.7.29, for macos10.14 (x86_64) +-- +-- Host: 127.0.0.1 Database: pop_test +-- ------------------------------------------------------ +-- Server version 5.7.31 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `e2e_user_posts` +-- + +DROP TABLE IF EXISTS `e2e_user_posts`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `e2e_user_posts` ( + `id` char(36) NOT NULL, + `user_id` char(36) NOT NULL, + `slug` varchar(32) NOT NULL, + `content` varchar(255) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + UNIQUE KEY `e2e_user_notes_slug_idx` (`slug`), + KEY `e2e_user_notes_user_id_idx` (`user_id`), + CONSTRAINT `e2e_user_posts_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `e2e_users` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `e2e_users` +-- + +DROP TABLE IF EXISTS `e2e_users`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `e2e_users` ( + `id` char(36) NOT NULL, + `created_at` datetime NOT NULL, + `updated_at` datetime NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `schema_migration` +-- + +DROP TABLE IF EXISTS `schema_migration`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `schema_migration` ( + `version` varchar(14) NOT NULL, + UNIQUE KEY `schema_migration_version_idx` (`version`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2020-08-27 23:39:23 diff --git a/internal/e2e/fixtures/mysql/up/2.sql b/internal/e2e/fixtures/mysql/up/2.sql index 78f1cc2c..bf6a159c 100644 --- a/internal/e2e/fixtures/mysql/up/2.sql +++ b/internal/e2e/fixtures/mysql/up/2.sql @@ -2,7 +2,7 @@ -- -- Host: 127.0.0.1 Database: pop_test -- ------------------------------------------------------ --- Server version 5.7.30 +-- Server version 5.7.31 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -41,6 +41,7 @@ DROP TABLE IF EXISTS `e2e_users`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `e2e_users` ( `id` char(36) NOT NULL, + `username` varchar(255) DEFAULT NULL, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, PRIMARY KEY (`id`) @@ -69,4 +70,4 @@ CREATE TABLE `schema_migration` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-06-20 18:55:52 +-- Dump completed on 2020-08-27 23:39:22 diff --git a/internal/e2e/fixtures/mysql/up/3.sql b/internal/e2e/fixtures/mysql/up/3.sql index 68a229d4..b69109a0 100644 --- a/internal/e2e/fixtures/mysql/up/3.sql +++ b/internal/e2e/fixtures/mysql/up/3.sql @@ -2,7 +2,7 @@ -- -- Host: 127.0.0.1 Database: pop_test -- ------------------------------------------------------ --- Server version 5.7.30 +-- Server version 5.7.31 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -42,6 +42,7 @@ DROP TABLE IF EXISTS `e2e_users`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `e2e_users` ( `id` char(36) NOT NULL, + `username` varchar(255) DEFAULT NULL, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, PRIMARY KEY (`id`) @@ -70,4 +71,4 @@ CREATE TABLE `schema_migration` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-06-20 18:55:52 +-- Dump completed on 2020-08-27 23:39:22 diff --git a/internal/e2e/fixtures/mysql/up/4.sql b/internal/e2e/fixtures/mysql/up/4.sql index 68a229d4..b69109a0 100644 --- a/internal/e2e/fixtures/mysql/up/4.sql +++ b/internal/e2e/fixtures/mysql/up/4.sql @@ -2,7 +2,7 @@ -- -- Host: 127.0.0.1 Database: pop_test -- ------------------------------------------------------ --- Server version 5.7.30 +-- Server version 5.7.31 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -42,6 +42,7 @@ DROP TABLE IF EXISTS `e2e_users`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `e2e_users` ( `id` char(36) NOT NULL, + `username` varchar(255) DEFAULT NULL, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, PRIMARY KEY (`id`) @@ -70,4 +71,4 @@ CREATE TABLE `schema_migration` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-06-20 18:55:52 +-- Dump completed on 2020-08-27 23:39:22 diff --git a/internal/e2e/fixtures/mysql/up/5.sql b/internal/e2e/fixtures/mysql/up/5.sql index e300ae3e..02178e14 100644 --- a/internal/e2e/fixtures/mysql/up/5.sql +++ b/internal/e2e/fixtures/mysql/up/5.sql @@ -2,7 +2,7 @@ -- -- Host: 127.0.0.1 Database: pop_test -- ------------------------------------------------------ --- Server version 5.7.30 +-- Server version 5.7.31 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -43,6 +43,7 @@ DROP TABLE IF EXISTS `e2e_users`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `e2e_users` ( `id` char(36) NOT NULL, + `username` varchar(255) DEFAULT NULL, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, PRIMARY KEY (`id`) @@ -71,4 +72,4 @@ CREATE TABLE `schema_migration` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-06-20 18:55:53 +-- Dump completed on 2020-08-27 23:39:22 diff --git a/internal/e2e/fixtures/mysql/up/6.sql b/internal/e2e/fixtures/mysql/up/6.sql index d8ade9d4..f5ed02d7 100644 --- a/internal/e2e/fixtures/mysql/up/6.sql +++ b/internal/e2e/fixtures/mysql/up/6.sql @@ -2,7 +2,7 @@ -- -- Host: 127.0.0.1 Database: pop_test -- ------------------------------------------------------ --- Server version 5.7.30 +-- Server version 5.7.31 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -43,6 +43,7 @@ DROP TABLE IF EXISTS `e2e_users`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `e2e_users` ( `id` char(36) NOT NULL, + `username` varchar(255) DEFAULT NULL, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, PRIMARY KEY (`id`) @@ -71,4 +72,4 @@ CREATE TABLE `schema_migration` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-06-20 18:55:53 +-- Dump completed on 2020-08-27 23:39:22 diff --git a/internal/e2e/fixtures/mysql/up/7.sql b/internal/e2e/fixtures/mysql/up/7.sql new file mode 100644 index 00000000..0975c50e --- /dev/null +++ b/internal/e2e/fixtures/mysql/up/7.sql @@ -0,0 +1,75 @@ +-- MySQL dump 10.13 Distrib 5.7.29, for macos10.14 (x86_64) +-- +-- Host: 127.0.0.1 Database: pop_test +-- ------------------------------------------------------ +-- Server version 5.7.31 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `e2e_user_posts` +-- + +DROP TABLE IF EXISTS `e2e_user_posts`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `e2e_user_posts` ( + `id` char(36) NOT NULL, + `user_id` char(36) NOT NULL, + `slug` varchar(64) NOT NULL, + `content` varchar(255) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + UNIQUE KEY `e2e_user_notes_slug_idx` (`slug`), + KEY `e2e_user_notes_user_id_idx` (`user_id`), + CONSTRAINT `e2e_user_posts_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `e2e_users` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `e2e_users` +-- + +DROP TABLE IF EXISTS `e2e_users`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `e2e_users` ( + `id` char(36) NOT NULL, + `username` varchar(255) DEFAULT NULL, + `created_at` datetime NOT NULL, + `updated_at` datetime NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `schema_migration` +-- + +DROP TABLE IF EXISTS `schema_migration`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `schema_migration` ( + `version` varchar(14) NOT NULL, + UNIQUE KEY `schema_migration_version_idx` (`version`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2020-08-27 23:39:22 diff --git a/internal/e2e/fixtures/mysql/up/8.sql b/internal/e2e/fixtures/mysql/up/8.sql new file mode 100644 index 00000000..d68ae699 --- /dev/null +++ b/internal/e2e/fixtures/mysql/up/8.sql @@ -0,0 +1,75 @@ +-- MySQL dump 10.13 Distrib 5.7.29, for macos10.14 (x86_64) +-- +-- Host: 127.0.0.1 Database: pop_test +-- ------------------------------------------------------ +-- Server version 5.7.31 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `e2e_user_posts` +-- + +DROP TABLE IF EXISTS `e2e_user_posts`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `e2e_user_posts` ( + `id` char(36) NOT NULL, + `user_id` char(36) NOT NULL, + `slug` varchar(64) NOT NULL, + `content` varchar(255) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + UNIQUE KEY `e2e_user_notes_slug_idx` (`slug`), + KEY `e2e_user_notes_user_id_idx` (`user_id`), + CONSTRAINT `e2e_user_posts_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `e2e_users` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `e2e_users` +-- + +DROP TABLE IF EXISTS `e2e_users`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `e2e_users` ( + `id` char(36) NOT NULL, + `name` varchar(255) DEFAULT NULL, + `created_at` datetime NOT NULL, + `updated_at` datetime NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `schema_migration` +-- + +DROP TABLE IF EXISTS `schema_migration`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `schema_migration` ( + `version` varchar(14) NOT NULL, + UNIQUE KEY `schema_migration_version_idx` (`version`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2020-08-27 23:39:23 diff --git a/internal/e2e/fixtures/mysql/up/9.sql b/internal/e2e/fixtures/mysql/up/9.sql new file mode 100644 index 00000000..335b6cd1 --- /dev/null +++ b/internal/e2e/fixtures/mysql/up/9.sql @@ -0,0 +1,74 @@ +-- MySQL dump 10.13 Distrib 5.7.29, for macos10.14 (x86_64) +-- +-- Host: 127.0.0.1 Database: pop_test +-- ------------------------------------------------------ +-- Server version 5.7.31 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `e2e_user_posts` +-- + +DROP TABLE IF EXISTS `e2e_user_posts`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `e2e_user_posts` ( + `id` char(36) NOT NULL, + `user_id` char(36) NOT NULL, + `slug` varchar(64) NOT NULL, + `content` varchar(255) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + UNIQUE KEY `e2e_user_notes_slug_idx` (`slug`), + KEY `e2e_user_notes_user_id_idx` (`user_id`), + CONSTRAINT `e2e_user_posts_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `e2e_users` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `e2e_users` +-- + +DROP TABLE IF EXISTS `e2e_users`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `e2e_users` ( + `id` char(36) NOT NULL, + `created_at` datetime NOT NULL, + `updated_at` datetime NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `schema_migration` +-- + +DROP TABLE IF EXISTS `schema_migration`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `schema_migration` ( + `version` varchar(14) NOT NULL, + UNIQUE KEY `schema_migration_version_idx` (`version`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2020-08-27 23:39:23 diff --git a/internal/e2e/fixtures/postgres/down/1.sql b/internal/e2e/fixtures/postgres/down/1.sql index 9aa925a8..3536360f 100644 --- a/internal/e2e/fixtures/postgres/down/1.sql +++ b/internal/e2e/fixtures/postgres/down/1.sql @@ -2,8 +2,8 @@ -- PostgreSQL database dump -- --- Dumped from database version 9.6.18 --- Dumped by pg_dump version 12.3 +-- Dumped from database version 9.6.19 +-- Dumped by pg_dump version 12.4 SET statement_timeout = 0; SET lock_timeout = 0; @@ -24,9 +24,9 @@ SET default_tablespace = ''; CREATE TABLE public.e2e_users ( id uuid NOT NULL, - username character varying(255), created_at timestamp without time zone NOT NULL, - updated_at timestamp without time zone NOT NULL + updated_at timestamp without time zone NOT NULL, + username character varying(255) ); diff --git a/internal/e2e/fixtures/postgres/down/10.sql b/internal/e2e/fixtures/postgres/down/10.sql new file mode 100644 index 00000000..013b24e3 --- /dev/null +++ b/internal/e2e/fixtures/postgres/down/10.sql @@ -0,0 +1,107 @@ +-- +-- PostgreSQL database dump +-- + +-- Dumped from database version 9.6.19 +-- Dumped by pg_dump version 12.4 + +SET statement_timeout = 0; +SET lock_timeout = 0; +SET idle_in_transaction_session_timeout = 0; +SET client_encoding = 'UTF8'; +SET standard_conforming_strings = on; +SELECT pg_catalog.set_config('search_path', '', false); +SET check_function_bodies = false; +SET xmloption = content; +SET client_min_messages = warning; +SET row_security = off; + +SET default_tablespace = ''; + +-- +-- Name: e2e_user_posts; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.e2e_user_posts ( + id uuid NOT NULL, + user_id uuid NOT NULL, + slug character varying(64) NOT NULL, + content character varying(255) DEFAULT ''::character varying NOT NULL +); + + +ALTER TABLE public.e2e_user_posts OWNER TO postgres; + +-- +-- Name: e2e_users; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.e2e_users ( + id uuid NOT NULL, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL +); + + +ALTER TABLE public.e2e_users OWNER TO postgres; + +-- +-- Name: schema_migration; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.schema_migration ( + version character varying(14) NOT NULL +); + + +ALTER TABLE public.schema_migration OWNER TO postgres; + +-- +-- Name: e2e_user_posts e2e_user_notes_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.e2e_user_posts + ADD CONSTRAINT e2e_user_notes_pkey PRIMARY KEY (id); + + +-- +-- Name: e2e_users e2e_users_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.e2e_users + ADD CONSTRAINT e2e_users_pkey PRIMARY KEY (id); + + +-- +-- Name: e2e_user_notes_slug_idx; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX e2e_user_notes_slug_idx ON public.e2e_user_posts USING btree (slug); + + +-- +-- Name: e2e_user_notes_user_id_idx; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX e2e_user_notes_user_id_idx ON public.e2e_user_posts USING btree (user_id); + + +-- +-- Name: schema_migration_version_idx; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX schema_migration_version_idx ON public.schema_migration USING btree (version); + + +-- +-- Name: e2e_user_posts e2e_user_notes_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.e2e_user_posts + ADD CONSTRAINT e2e_user_notes_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.e2e_users(id) ON DELETE CASCADE; + + +-- +-- PostgreSQL database dump complete +-- + diff --git a/internal/e2e/fixtures/postgres/down/2.sql b/internal/e2e/fixtures/postgres/down/2.sql index 773f7299..95c59a8d 100644 --- a/internal/e2e/fixtures/postgres/down/2.sql +++ b/internal/e2e/fixtures/postgres/down/2.sql @@ -2,8 +2,8 @@ -- PostgreSQL database dump -- --- Dumped from database version 9.6.18 --- Dumped by pg_dump version 12.3 +-- Dumped from database version 9.6.19 +-- Dumped by pg_dump version 12.4 SET statement_timeout = 0; SET lock_timeout = 0; @@ -38,9 +38,9 @@ ALTER TABLE public.e2e_user_notes OWNER TO postgres; CREATE TABLE public.e2e_users ( id uuid NOT NULL, - username character varying(255), created_at timestamp without time zone NOT NULL, - updated_at timestamp without time zone NOT NULL + updated_at timestamp without time zone NOT NULL, + username character varying(255) ); diff --git a/internal/e2e/fixtures/postgres/down/3.sql b/internal/e2e/fixtures/postgres/down/3.sql index 553c797c..ea80a8e3 100644 --- a/internal/e2e/fixtures/postgres/down/3.sql +++ b/internal/e2e/fixtures/postgres/down/3.sql @@ -2,8 +2,8 @@ -- PostgreSQL database dump -- --- Dumped from database version 9.6.18 --- Dumped by pg_dump version 12.3 +-- Dumped from database version 9.6.19 +-- Dumped by pg_dump version 12.4 SET statement_timeout = 0; SET lock_timeout = 0; @@ -37,9 +37,9 @@ ALTER TABLE public.e2e_user_notes OWNER TO postgres; CREATE TABLE public.e2e_users ( id uuid NOT NULL, - username character varying(255), created_at timestamp without time zone NOT NULL, - updated_at timestamp without time zone NOT NULL + updated_at timestamp without time zone NOT NULL, + username character varying(255) ); diff --git a/internal/e2e/fixtures/postgres/down/4.sql b/internal/e2e/fixtures/postgres/down/4.sql index ec4649e3..bdb95120 100644 --- a/internal/e2e/fixtures/postgres/down/4.sql +++ b/internal/e2e/fixtures/postgres/down/4.sql @@ -2,8 +2,8 @@ -- PostgreSQL database dump -- --- Dumped from database version 9.6.18 --- Dumped by pg_dump version 12.3 +-- Dumped from database version 9.6.19 +-- Dumped by pg_dump version 12.4 SET statement_timeout = 0; SET lock_timeout = 0; @@ -38,9 +38,9 @@ ALTER TABLE public.e2e_user_notes OWNER TO postgres; CREATE TABLE public.e2e_users ( id uuid NOT NULL, - username character varying(255), created_at timestamp without time zone NOT NULL, - updated_at timestamp without time zone NOT NULL + updated_at timestamp without time zone NOT NULL, + username character varying(255) ); diff --git a/internal/e2e/fixtures/postgres/down/5.sql b/internal/e2e/fixtures/postgres/down/5.sql index ec4649e3..bdb95120 100644 --- a/internal/e2e/fixtures/postgres/down/5.sql +++ b/internal/e2e/fixtures/postgres/down/5.sql @@ -2,8 +2,8 @@ -- PostgreSQL database dump -- --- Dumped from database version 9.6.18 --- Dumped by pg_dump version 12.3 +-- Dumped from database version 9.6.19 +-- Dumped by pg_dump version 12.4 SET statement_timeout = 0; SET lock_timeout = 0; @@ -38,9 +38,9 @@ ALTER TABLE public.e2e_user_notes OWNER TO postgres; CREATE TABLE public.e2e_users ( id uuid NOT NULL, - username character varying(255), created_at timestamp without time zone NOT NULL, - updated_at timestamp without time zone NOT NULL + updated_at timestamp without time zone NOT NULL, + username character varying(255) ); diff --git a/internal/e2e/fixtures/postgres/down/6.sql b/internal/e2e/fixtures/postgres/down/6.sql index ec4649e3..bdb95120 100644 --- a/internal/e2e/fixtures/postgres/down/6.sql +++ b/internal/e2e/fixtures/postgres/down/6.sql @@ -2,8 +2,8 @@ -- PostgreSQL database dump -- --- Dumped from database version 9.6.18 --- Dumped by pg_dump version 12.3 +-- Dumped from database version 9.6.19 +-- Dumped by pg_dump version 12.4 SET statement_timeout = 0; SET lock_timeout = 0; @@ -38,9 +38,9 @@ ALTER TABLE public.e2e_user_notes OWNER TO postgres; CREATE TABLE public.e2e_users ( id uuid NOT NULL, - username character varying(255), created_at timestamp without time zone NOT NULL, - updated_at timestamp without time zone NOT NULL + updated_at timestamp without time zone NOT NULL, + username character varying(255) ); diff --git a/internal/e2e/fixtures/postgres/down/7.sql b/internal/e2e/fixtures/postgres/down/7.sql index 0d4bd32b..5632aa96 100644 --- a/internal/e2e/fixtures/postgres/down/7.sql +++ b/internal/e2e/fixtures/postgres/down/7.sql @@ -2,8 +2,8 @@ -- PostgreSQL database dump -- --- Dumped from database version 9.6.18 --- Dumped by pg_dump version 12.3 +-- Dumped from database version 9.6.19 +-- Dumped by pg_dump version 12.4 SET statement_timeout = 0; SET lock_timeout = 0; @@ -38,9 +38,9 @@ ALTER TABLE public.e2e_user_posts OWNER TO postgres; CREATE TABLE public.e2e_users ( id uuid NOT NULL, - username character varying(255), created_at timestamp without time zone NOT NULL, - updated_at timestamp without time zone NOT NULL + updated_at timestamp without time zone NOT NULL, + username character varying(255) ); diff --git a/internal/e2e/fixtures/postgres/down/8.sql b/internal/e2e/fixtures/postgres/down/8.sql index ee3cae65..e13e666a 100644 --- a/internal/e2e/fixtures/postgres/down/8.sql +++ b/internal/e2e/fixtures/postgres/down/8.sql @@ -2,8 +2,8 @@ -- PostgreSQL database dump -- --- Dumped from database version 9.6.18 --- Dumped by pg_dump version 12.3 +-- Dumped from database version 9.6.19 +-- Dumped by pg_dump version 12.4 SET statement_timeout = 0; SET lock_timeout = 0; @@ -38,9 +38,9 @@ ALTER TABLE public.e2e_user_posts OWNER TO postgres; CREATE TABLE public.e2e_users ( id uuid NOT NULL, - username character varying(255), created_at timestamp without time zone NOT NULL, - updated_at timestamp without time zone NOT NULL + updated_at timestamp without time zone NOT NULL, + username character varying(255) ); diff --git a/internal/e2e/fixtures/postgres/down/9.sql b/internal/e2e/fixtures/postgres/down/9.sql new file mode 100644 index 00000000..3055d073 --- /dev/null +++ b/internal/e2e/fixtures/postgres/down/9.sql @@ -0,0 +1,108 @@ +-- +-- PostgreSQL database dump +-- + +-- Dumped from database version 9.6.19 +-- Dumped by pg_dump version 12.4 + +SET statement_timeout = 0; +SET lock_timeout = 0; +SET idle_in_transaction_session_timeout = 0; +SET client_encoding = 'UTF8'; +SET standard_conforming_strings = on; +SELECT pg_catalog.set_config('search_path', '', false); +SET check_function_bodies = false; +SET xmloption = content; +SET client_min_messages = warning; +SET row_security = off; + +SET default_tablespace = ''; + +-- +-- Name: e2e_user_posts; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.e2e_user_posts ( + id uuid NOT NULL, + user_id uuid NOT NULL, + slug character varying(64) NOT NULL, + content character varying(255) DEFAULT ''::character varying NOT NULL +); + + +ALTER TABLE public.e2e_user_posts OWNER TO postgres; + +-- +-- Name: e2e_users; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.e2e_users ( + id uuid NOT NULL, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, + name character varying(255) +); + + +ALTER TABLE public.e2e_users OWNER TO postgres; + +-- +-- Name: schema_migration; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.schema_migration ( + version character varying(14) NOT NULL +); + + +ALTER TABLE public.schema_migration OWNER TO postgres; + +-- +-- Name: e2e_user_posts e2e_user_notes_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.e2e_user_posts + ADD CONSTRAINT e2e_user_notes_pkey PRIMARY KEY (id); + + +-- +-- Name: e2e_users e2e_users_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.e2e_users + ADD CONSTRAINT e2e_users_pkey PRIMARY KEY (id); + + +-- +-- Name: e2e_user_notes_slug_idx; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX e2e_user_notes_slug_idx ON public.e2e_user_posts USING btree (slug); + + +-- +-- Name: e2e_user_notes_user_id_idx; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX e2e_user_notes_user_id_idx ON public.e2e_user_posts USING btree (user_id); + + +-- +-- Name: schema_migration_version_idx; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX schema_migration_version_idx ON public.schema_migration USING btree (version); + + +-- +-- Name: e2e_user_posts e2e_user_notes_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.e2e_user_posts + ADD CONSTRAINT e2e_user_notes_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.e2e_users(id) ON DELETE CASCADE; + + +-- +-- PostgreSQL database dump complete +-- + diff --git a/internal/e2e/fixtures/postgres/up/10.sql b/internal/e2e/fixtures/postgres/up/10.sql new file mode 100644 index 00000000..b8dbc7a9 --- /dev/null +++ b/internal/e2e/fixtures/postgres/up/10.sql @@ -0,0 +1,107 @@ +-- +-- PostgreSQL database dump +-- + +-- Dumped from database version 9.6.19 +-- Dumped by pg_dump version 12.4 + +SET statement_timeout = 0; +SET lock_timeout = 0; +SET idle_in_transaction_session_timeout = 0; +SET client_encoding = 'UTF8'; +SET standard_conforming_strings = on; +SELECT pg_catalog.set_config('search_path', '', false); +SET check_function_bodies = false; +SET xmloption = content; +SET client_min_messages = warning; +SET row_security = off; + +SET default_tablespace = ''; + +-- +-- Name: e2e_user_posts; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.e2e_user_posts ( + id uuid NOT NULL, + user_id uuid NOT NULL, + slug character varying(32) NOT NULL, + content character varying(255) DEFAULT ''::character varying NOT NULL +); + + +ALTER TABLE public.e2e_user_posts OWNER TO postgres; + +-- +-- Name: e2e_users; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.e2e_users ( + id uuid NOT NULL, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL +); + + +ALTER TABLE public.e2e_users OWNER TO postgres; + +-- +-- Name: schema_migration; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.schema_migration ( + version character varying(14) NOT NULL +); + + +ALTER TABLE public.schema_migration OWNER TO postgres; + +-- +-- Name: e2e_user_posts e2e_user_notes_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.e2e_user_posts + ADD CONSTRAINT e2e_user_notes_pkey PRIMARY KEY (id); + + +-- +-- Name: e2e_users e2e_users_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.e2e_users + ADD CONSTRAINT e2e_users_pkey PRIMARY KEY (id); + + +-- +-- Name: e2e_user_notes_slug_idx; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX e2e_user_notes_slug_idx ON public.e2e_user_posts USING btree (slug); + + +-- +-- Name: e2e_user_notes_user_id_idx; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX e2e_user_notes_user_id_idx ON public.e2e_user_posts USING btree (user_id); + + +-- +-- Name: schema_migration_version_idx; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX schema_migration_version_idx ON public.schema_migration USING btree (version); + + +-- +-- Name: e2e_user_posts e2e_user_notes_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.e2e_user_posts + ADD CONSTRAINT e2e_user_notes_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.e2e_users(id) ON DELETE CASCADE; + + +-- +-- PostgreSQL database dump complete +-- + diff --git a/internal/e2e/fixtures/postgres/up/9.sql b/internal/e2e/fixtures/postgres/up/9.sql new file mode 100644 index 00000000..013b24e3 --- /dev/null +++ b/internal/e2e/fixtures/postgres/up/9.sql @@ -0,0 +1,107 @@ +-- +-- PostgreSQL database dump +-- + +-- Dumped from database version 9.6.19 +-- Dumped by pg_dump version 12.4 + +SET statement_timeout = 0; +SET lock_timeout = 0; +SET idle_in_transaction_session_timeout = 0; +SET client_encoding = 'UTF8'; +SET standard_conforming_strings = on; +SELECT pg_catalog.set_config('search_path', '', false); +SET check_function_bodies = false; +SET xmloption = content; +SET client_min_messages = warning; +SET row_security = off; + +SET default_tablespace = ''; + +-- +-- Name: e2e_user_posts; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.e2e_user_posts ( + id uuid NOT NULL, + user_id uuid NOT NULL, + slug character varying(64) NOT NULL, + content character varying(255) DEFAULT ''::character varying NOT NULL +); + + +ALTER TABLE public.e2e_user_posts OWNER TO postgres; + +-- +-- Name: e2e_users; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.e2e_users ( + id uuid NOT NULL, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL +); + + +ALTER TABLE public.e2e_users OWNER TO postgres; + +-- +-- Name: schema_migration; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.schema_migration ( + version character varying(14) NOT NULL +); + + +ALTER TABLE public.schema_migration OWNER TO postgres; + +-- +-- Name: e2e_user_posts e2e_user_notes_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.e2e_user_posts + ADD CONSTRAINT e2e_user_notes_pkey PRIMARY KEY (id); + + +-- +-- Name: e2e_users e2e_users_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.e2e_users + ADD CONSTRAINT e2e_users_pkey PRIMARY KEY (id); + + +-- +-- Name: e2e_user_notes_slug_idx; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX e2e_user_notes_slug_idx ON public.e2e_user_posts USING btree (slug); + + +-- +-- Name: e2e_user_notes_user_id_idx; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX e2e_user_notes_user_id_idx ON public.e2e_user_posts USING btree (user_id); + + +-- +-- Name: schema_migration_version_idx; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX schema_migration_version_idx ON public.schema_migration USING btree (version); + + +-- +-- Name: e2e_user_posts e2e_user_notes_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.e2e_user_posts + ADD CONSTRAINT e2e_user_notes_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.e2e_users(id) ON DELETE CASCADE; + + +-- +-- PostgreSQL database dump complete +-- + diff --git a/internal/e2e/fixtures/sqlite3/down/1.sql b/internal/e2e/fixtures/sqlite3/down/1.sql index 50fab927..a8e5ee78 100644 --- a/internal/e2e/fixtures/sqlite3/down/1.sql +++ b/internal/e2e/fixtures/sqlite3/down/1.sql @@ -4,7 +4,6 @@ CREATE TABLE IF NOT EXISTS "schema_migration" ( CREATE UNIQUE INDEX "schema_migration_version_idx" ON "schema_migration" (version); CREATE TABLE IF NOT EXISTS "e2e_users" ( "id" TEXT PRIMARY KEY, -"username" TEXT, "created_at" DATETIME NOT NULL, "updated_at" DATETIME NOT NULL -); +, "username" TEXT); diff --git a/internal/e2e/fixtures/sqlite3/down/10.sql b/internal/e2e/fixtures/sqlite3/down/10.sql new file mode 100644 index 00000000..6b688e85 --- /dev/null +++ b/internal/e2e/fixtures/sqlite3/down/10.sql @@ -0,0 +1,18 @@ +CREATE TABLE IF NOT EXISTS "schema_migration" ( +"version" TEXT NOT NULL +); +CREATE UNIQUE INDEX "schema_migration_version_idx" ON "schema_migration" (version); +CREATE TABLE IF NOT EXISTS "e2e_users" ( +"id" TEXT PRIMARY KEY, +"created_at" DATETIME NOT NULL, +"updated_at" DATETIME NOT NULL +); +CREATE TABLE IF NOT EXISTS "e2e_user_posts" ( +"id" TEXT PRIMARY KEY, +"user_id" char(36) NOT NULL, +"slug" TEXT NOT NULL, +"content" TEXT NOT NULL DEFAULT '', +FOREIGN KEY (user_id) REFERENCES e2e_users (id) ON UPDATE NO ACTION ON DELETE CASCADE +); +CREATE UNIQUE INDEX "e2e_user_notes_slug_idx" ON "e2e_user_posts" (slug); +CREATE INDEX "e2e_user_notes_user_id_idx" ON "e2e_user_posts" (user_id); diff --git a/internal/e2e/fixtures/sqlite3/down/2.sql b/internal/e2e/fixtures/sqlite3/down/2.sql index 8d58587f..8b14e578 100644 --- a/internal/e2e/fixtures/sqlite3/down/2.sql +++ b/internal/e2e/fixtures/sqlite3/down/2.sql @@ -4,14 +4,14 @@ CREATE TABLE IF NOT EXISTS "schema_migration" ( CREATE UNIQUE INDEX "schema_migration_version_idx" ON "schema_migration" (version); CREATE TABLE IF NOT EXISTS "e2e_users" ( "id" TEXT PRIMARY KEY, -"username" TEXT, "created_at" DATETIME NOT NULL, "updated_at" DATETIME NOT NULL -); +, "username" TEXT); CREATE TABLE IF NOT EXISTS "e2e_user_notes" ( "id" TEXT PRIMARY KEY, "user_id" char(36) NOT NULL, "notes" TEXT, "title" TEXT NOT NULL DEFAULT '', FOREIGN KEY (user_id) REFERENCES e2e_users (id) ON UPDATE NO ACTION ON DELETE CASCADE ); +CREATE INDEX "e2e_user_notes_user_id_idx" ON "e2e_user_notes" (user_id); CREATE INDEX "e2e_user_notes_title_idx" ON "e2e_user_notes" (title); diff --git a/internal/e2e/fixtures/sqlite3/down/3.sql b/internal/e2e/fixtures/sqlite3/down/3.sql index 263ab8b5..0bc61428 100644 --- a/internal/e2e/fixtures/sqlite3/down/3.sql +++ b/internal/e2e/fixtures/sqlite3/down/3.sql @@ -4,13 +4,13 @@ CREATE TABLE IF NOT EXISTS "schema_migration" ( CREATE UNIQUE INDEX "schema_migration_version_idx" ON "schema_migration" (version); CREATE TABLE IF NOT EXISTS "e2e_users" ( "id" TEXT PRIMARY KEY, -"username" TEXT, "created_at" DATETIME NOT NULL, "updated_at" DATETIME NOT NULL -); +, "username" TEXT); CREATE TABLE IF NOT EXISTS "e2e_user_notes" ( "id" TEXT PRIMARY KEY, "user_id" char(36) NOT NULL, "notes" TEXT, FOREIGN KEY (user_id) REFERENCES e2e_users (id) ON UPDATE NO ACTION ON DELETE CASCADE ); +CREATE INDEX "e2e_user_notes_user_id_idx" ON "e2e_user_notes" (user_id); diff --git a/internal/e2e/fixtures/sqlite3/down/4.sql b/internal/e2e/fixtures/sqlite3/down/4.sql index 4f65ec3e..85702e6e 100644 --- a/internal/e2e/fixtures/sqlite3/down/4.sql +++ b/internal/e2e/fixtures/sqlite3/down/4.sql @@ -4,14 +4,14 @@ CREATE TABLE IF NOT EXISTS "schema_migration" ( CREATE UNIQUE INDEX "schema_migration_version_idx" ON "schema_migration" (version); CREATE TABLE IF NOT EXISTS "e2e_users" ( "id" TEXT PRIMARY KEY, -"username" TEXT, "created_at" DATETIME NOT NULL, "updated_at" DATETIME NOT NULL -); +, "username" TEXT); CREATE TABLE IF NOT EXISTS "e2e_user_notes" ( "id" TEXT PRIMARY KEY, "user_id" char(36) NOT NULL, "slug" TEXT NOT NULL, "notes" TEXT, FOREIGN KEY (user_id) REFERENCES e2e_users (id) ON UPDATE NO ACTION ON DELETE CASCADE ); +CREATE INDEX "e2e_user_notes_user_id_idx" ON "e2e_user_notes" (user_id); CREATE UNIQUE INDEX "e2e_user_notes_slug_idx" ON "e2e_user_notes" (slug); diff --git a/internal/e2e/fixtures/sqlite3/down/5.sql b/internal/e2e/fixtures/sqlite3/down/5.sql index 4f65ec3e..85702e6e 100644 --- a/internal/e2e/fixtures/sqlite3/down/5.sql +++ b/internal/e2e/fixtures/sqlite3/down/5.sql @@ -4,14 +4,14 @@ CREATE TABLE IF NOT EXISTS "schema_migration" ( CREATE UNIQUE INDEX "schema_migration_version_idx" ON "schema_migration" (version); CREATE TABLE IF NOT EXISTS "e2e_users" ( "id" TEXT PRIMARY KEY, -"username" TEXT, "created_at" DATETIME NOT NULL, "updated_at" DATETIME NOT NULL -); +, "username" TEXT); CREATE TABLE IF NOT EXISTS "e2e_user_notes" ( "id" TEXT PRIMARY KEY, "user_id" char(36) NOT NULL, "slug" TEXT NOT NULL, "notes" TEXT, FOREIGN KEY (user_id) REFERENCES e2e_users (id) ON UPDATE NO ACTION ON DELETE CASCADE ); +CREATE INDEX "e2e_user_notes_user_id_idx" ON "e2e_user_notes" (user_id); CREATE UNIQUE INDEX "e2e_user_notes_slug_idx" ON "e2e_user_notes" (slug); diff --git a/internal/e2e/fixtures/sqlite3/down/6.sql b/internal/e2e/fixtures/sqlite3/down/6.sql index 4f65ec3e..85702e6e 100644 --- a/internal/e2e/fixtures/sqlite3/down/6.sql +++ b/internal/e2e/fixtures/sqlite3/down/6.sql @@ -4,14 +4,14 @@ CREATE TABLE IF NOT EXISTS "schema_migration" ( CREATE UNIQUE INDEX "schema_migration_version_idx" ON "schema_migration" (version); CREATE TABLE IF NOT EXISTS "e2e_users" ( "id" TEXT PRIMARY KEY, -"username" TEXT, "created_at" DATETIME NOT NULL, "updated_at" DATETIME NOT NULL -); +, "username" TEXT); CREATE TABLE IF NOT EXISTS "e2e_user_notes" ( "id" TEXT PRIMARY KEY, "user_id" char(36) NOT NULL, "slug" TEXT NOT NULL, "notes" TEXT, FOREIGN KEY (user_id) REFERENCES e2e_users (id) ON UPDATE NO ACTION ON DELETE CASCADE ); +CREATE INDEX "e2e_user_notes_user_id_idx" ON "e2e_user_notes" (user_id); CREATE UNIQUE INDEX "e2e_user_notes_slug_idx" ON "e2e_user_notes" (slug); diff --git a/internal/e2e/fixtures/sqlite3/down/7.sql b/internal/e2e/fixtures/sqlite3/down/7.sql index dfe7f4f4..3620a06f 100644 --- a/internal/e2e/fixtures/sqlite3/down/7.sql +++ b/internal/e2e/fixtures/sqlite3/down/7.sql @@ -4,14 +4,14 @@ CREATE TABLE IF NOT EXISTS "schema_migration" ( CREATE UNIQUE INDEX "schema_migration_version_idx" ON "schema_migration" (version); CREATE TABLE IF NOT EXISTS "e2e_users" ( "id" TEXT PRIMARY KEY, -"username" TEXT, "created_at" DATETIME NOT NULL, "updated_at" DATETIME NOT NULL -); +, "username" TEXT); CREATE TABLE IF NOT EXISTS "e2e_user_posts" ( "id" TEXT PRIMARY KEY, "user_id" char(36) NOT NULL, "slug" TEXT NOT NULL, "notes" TEXT, FOREIGN KEY (user_id) REFERENCES e2e_users (id) ON UPDATE NO ACTION ON DELETE CASCADE ); +CREATE INDEX "e2e_user_notes_user_id_idx" ON "e2e_user_posts" (user_id); CREATE UNIQUE INDEX "e2e_user_notes_slug_idx" ON "e2e_user_posts" (slug); diff --git a/internal/e2e/fixtures/sqlite3/down/8.sql b/internal/e2e/fixtures/sqlite3/down/8.sql index 2da12c4a..520a5028 100644 --- a/internal/e2e/fixtures/sqlite3/down/8.sql +++ b/internal/e2e/fixtures/sqlite3/down/8.sql @@ -4,10 +4,9 @@ CREATE TABLE IF NOT EXISTS "schema_migration" ( CREATE UNIQUE INDEX "schema_migration_version_idx" ON "schema_migration" (version); CREATE TABLE IF NOT EXISTS "e2e_users" ( "id" TEXT PRIMARY KEY, -"username" TEXT, "created_at" DATETIME NOT NULL, "updated_at" DATETIME NOT NULL -); +, "username" TEXT); CREATE TABLE IF NOT EXISTS "e2e_user_posts" ( "id" TEXT PRIMARY KEY, "user_id" char(36) NOT NULL, @@ -16,3 +15,4 @@ CREATE TABLE IF NOT EXISTS "e2e_user_posts" ( FOREIGN KEY (user_id) REFERENCES e2e_users (id) ON UPDATE NO ACTION ON DELETE CASCADE ); CREATE UNIQUE INDEX "e2e_user_notes_slug_idx" ON "e2e_user_posts" (slug); +CREATE INDEX "e2e_user_notes_user_id_idx" ON "e2e_user_posts" (user_id); diff --git a/internal/e2e/fixtures/sqlite3/down/9.sql b/internal/e2e/fixtures/sqlite3/down/9.sql new file mode 100644 index 00000000..05acdb2a --- /dev/null +++ b/internal/e2e/fixtures/sqlite3/down/9.sql @@ -0,0 +1,18 @@ +CREATE TABLE IF NOT EXISTS "schema_migration" ( +"version" TEXT NOT NULL +); +CREATE UNIQUE INDEX "schema_migration_version_idx" ON "schema_migration" (version); +CREATE TABLE IF NOT EXISTS "e2e_users" ( +"id" TEXT PRIMARY KEY, +"created_at" DATETIME NOT NULL, +"updated_at" DATETIME NOT NULL +, "name" TEXT); +CREATE TABLE IF NOT EXISTS "e2e_user_posts" ( +"id" TEXT PRIMARY KEY, +"user_id" char(36) NOT NULL, +"slug" TEXT NOT NULL, +"content" TEXT NOT NULL DEFAULT '', +FOREIGN KEY (user_id) REFERENCES e2e_users (id) ON UPDATE NO ACTION ON DELETE CASCADE +); +CREATE UNIQUE INDEX "e2e_user_notes_slug_idx" ON "e2e_user_posts" (slug); +CREATE INDEX "e2e_user_notes_user_id_idx" ON "e2e_user_posts" (user_id); diff --git a/internal/e2e/fixtures/sqlite3/up/10.sql b/internal/e2e/fixtures/sqlite3/up/10.sql new file mode 100644 index 00000000..d3e88a50 --- /dev/null +++ b/internal/e2e/fixtures/sqlite3/up/10.sql @@ -0,0 +1,18 @@ +CREATE TABLE IF NOT EXISTS "schema_migration" ( +"version" TEXT NOT NULL +); +CREATE UNIQUE INDEX "schema_migration_version_idx" ON "schema_migration" (version); +CREATE TABLE IF NOT EXISTS "e2e_users" ( +"id" TEXT PRIMARY KEY, +"created_at" DATETIME NOT NULL, +"updated_at" DATETIME NOT NULL +); +CREATE TABLE IF NOT EXISTS "e2e_user_posts" ( +"id" TEXT PRIMARY KEY, +"user_id" char(36) NOT NULL, +"slug" TEXT NOT NULL, +"content" TEXT NOT NULL DEFAULT '', +FOREIGN KEY (user_id) REFERENCES e2e_users (id) ON UPDATE NO ACTION ON DELETE CASCADE +); +CREATE INDEX "e2e_user_notes_user_id_idx" ON "e2e_user_posts" (user_id); +CREATE UNIQUE INDEX "e2e_user_notes_slug_idx" ON "e2e_user_posts" (slug); diff --git a/internal/e2e/fixtures/sqlite3/up/5.sql b/internal/e2e/fixtures/sqlite3/up/5.sql index f8baaffe..439b16b4 100644 --- a/internal/e2e/fixtures/sqlite3/up/5.sql +++ b/internal/e2e/fixtures/sqlite3/up/5.sql @@ -15,4 +15,5 @@ CREATE TABLE IF NOT EXISTS "e2e_user_notes" ( "slug" TEXT NOT NULL, FOREIGN KEY (user_id) REFERENCES e2e_users (id) ON UPDATE NO ACTION ON DELETE CASCADE ); +CREATE INDEX "e2e_user_notes_user_id_idx" ON "e2e_user_notes" (user_id); CREATE UNIQUE INDEX "e2e_user_notes_slug_idx" ON "e2e_user_notes" (slug); diff --git a/internal/e2e/fixtures/sqlite3/up/6.sql b/internal/e2e/fixtures/sqlite3/up/6.sql index 1d25e4f7..03a02fdd 100644 --- a/internal/e2e/fixtures/sqlite3/up/6.sql +++ b/internal/e2e/fixtures/sqlite3/up/6.sql @@ -15,4 +15,5 @@ CREATE TABLE IF NOT EXISTS "e2e_user_posts" ( "slug" TEXT NOT NULL, FOREIGN KEY (user_id) REFERENCES e2e_users (id) ON UPDATE NO ACTION ON DELETE CASCADE ); +CREATE INDEX "e2e_user_notes_user_id_idx" ON "e2e_user_posts" (user_id); CREATE UNIQUE INDEX "e2e_user_notes_slug_idx" ON "e2e_user_posts" (slug); diff --git a/internal/e2e/fixtures/sqlite3/up/7.sql b/internal/e2e/fixtures/sqlite3/up/7.sql index 2da12c4a..87109179 100644 --- a/internal/e2e/fixtures/sqlite3/up/7.sql +++ b/internal/e2e/fixtures/sqlite3/up/7.sql @@ -16,3 +16,4 @@ CREATE TABLE IF NOT EXISTS "e2e_user_posts" ( FOREIGN KEY (user_id) REFERENCES e2e_users (id) ON UPDATE NO ACTION ON DELETE CASCADE ); CREATE UNIQUE INDEX "e2e_user_notes_slug_idx" ON "e2e_user_posts" (slug); +CREATE INDEX "e2e_user_notes_user_id_idx" ON "e2e_user_posts" (user_id); diff --git a/internal/e2e/fixtures/sqlite3/up/8.sql b/internal/e2e/fixtures/sqlite3/up/8.sql index ace37bd8..305400b6 100644 --- a/internal/e2e/fixtures/sqlite3/up/8.sql +++ b/internal/e2e/fixtures/sqlite3/up/8.sql @@ -16,3 +16,4 @@ CREATE TABLE IF NOT EXISTS "e2e_user_posts" ( FOREIGN KEY (user_id) REFERENCES e2e_users (id) ON UPDATE NO ACTION ON DELETE CASCADE ); CREATE UNIQUE INDEX "e2e_user_notes_slug_idx" ON "e2e_user_posts" (slug); +CREATE INDEX "e2e_user_notes_user_id_idx" ON "e2e_user_posts" (user_id); diff --git a/internal/e2e/fixtures/sqlite3/up/9.sql b/internal/e2e/fixtures/sqlite3/up/9.sql new file mode 100644 index 00000000..b2e49432 --- /dev/null +++ b/internal/e2e/fixtures/sqlite3/up/9.sql @@ -0,0 +1,18 @@ +CREATE TABLE IF NOT EXISTS "schema_migration" ( +"version" TEXT NOT NULL +); +CREATE UNIQUE INDEX "schema_migration_version_idx" ON "schema_migration" (version); +CREATE TABLE IF NOT EXISTS "e2e_user_posts" ( +"id" TEXT PRIMARY KEY, +"user_id" char(36) NOT NULL, +"slug" TEXT NOT NULL, +"content" TEXT NOT NULL DEFAULT '', +FOREIGN KEY (user_id) REFERENCES e2e_users (id) ON UPDATE NO ACTION ON DELETE CASCADE +); +CREATE UNIQUE INDEX "e2e_user_notes_slug_idx" ON "e2e_user_posts" (slug); +CREATE INDEX "e2e_user_notes_user_id_idx" ON "e2e_user_posts" (user_id); +CREATE TABLE IF NOT EXISTS "e2e_users" ( +"id" TEXT PRIMARY KEY, +"created_at" DATETIME NOT NULL, +"updated_at" DATETIME NOT NULL +); diff --git a/internal/e2e/migrations/20191100000010_users_drop_name.down.fizz b/internal/e2e/migrations/20191100000010_users_drop_name.down.fizz new file mode 100644 index 00000000..0d46aa3c --- /dev/null +++ b/internal/e2e/migrations/20191100000010_users_drop_name.down.fizz @@ -0,0 +1 @@ +add_column("e2e_users", "name", "string", {"null": true}) diff --git a/internal/e2e/migrations/20191100000010_users_drop_name.up.fizz b/internal/e2e/migrations/20191100000010_users_drop_name.up.fizz new file mode 100644 index 00000000..5336ffc5 --- /dev/null +++ b/internal/e2e/migrations/20191100000010_users_drop_name.up.fizz @@ -0,0 +1 @@ +drop_column("e2e_users", "name") diff --git a/internal/e2e/migrations/20191100000011_user_posts_change_column.down.fizz b/internal/e2e/migrations/20191100000011_user_posts_change_column.down.fizz new file mode 100644 index 00000000..c7d4f471 --- /dev/null +++ b/internal/e2e/migrations/20191100000011_user_posts_change_column.down.fizz @@ -0,0 +1 @@ +change_column("e2e_user_posts", "slug", "string", { "size": 64 }) diff --git a/internal/e2e/migrations/20191100000011_user_posts_change_column.up.fizz b/internal/e2e/migrations/20191100000011_user_posts_change_column.up.fizz new file mode 100644 index 00000000..59127cdc --- /dev/null +++ b/internal/e2e/migrations/20191100000011_user_posts_change_column.up.fizz @@ -0,0 +1 @@ +change_column("e2e_user_posts", "slug", "string", { "size": 32 }) \ No newline at end of file diff --git a/translators/cockroach.go b/translators/cockroach.go index b1f78f93..2e79957a 100644 --- a/translators/cockroach.go +++ b/translators/cockroach.go @@ -119,15 +119,35 @@ func (p *Cockroach) ChangeColumn(t fizz.Table) (string, error) { sql := []string{} s, err := p.withTempColumn(t.Name, c.Name, func(table fizz.Table, origCol fizz.Column, tempCol string) (string, error) { + var notNullWorkaround bool + if c.Options["default_raw"] == nil && c.Options["default"] == nil && c.Options["null"] == nil { + // This happens when the original column has "NOT NULL" and the changed column also has "NOT NULL" and no "DEFAULT". + // In those cases, if the table has data already, CockroachDB will fail with an error mandating that a column can not + // be added to the table unless it is either "NULL" or has a "DEFAULT". By first using NULL and then setting the + // "NOT NULL" constraint, this problem is worked around. + notNullWorkaround = true + } + newCol := p.buildChangeColumn(origCol, c) err1 := p.Schema.ReplaceColumn(table.Name, origCol.Name, newCol) if err1 != nil { return "", err1 } - createColumnSQL := fmt.Sprintf("ALTER TABLE \"%s\" ADD COLUMN %s;COMMIT TRANSACTION;BEGIN TRANSACTION;", table.Name, p.buildAddColumn(newCol)) - ins := fmt.Sprintf("UPDATE \"%s\" SET \"%s\" = \"%s\";COMMIT TRANSACTION;BEGIN TRANSACTION;", t.Name, c.Name, tempCol) - return strings.Join([]string{createColumnSQL, ins}, "\n"), nil + if notNullWorkaround { + newCol.Options["null"] = true + } + + createColumnSQL := fmt.Sprintf(`ALTER TABLE "%s" ADD COLUMN %s;COMMIT TRANSACTION;BEGIN TRANSACTION;`, table.Name, p.buildAddColumn(newCol)) + ins := fmt.Sprintf(`UPDATE "%s" SET "%s" = "%s";COMMIT TRANSACTION;BEGIN TRANSACTION;`, t.Name, c.Name, tempCol) + + sql := []string{createColumnSQL, ins} + if notNullWorkaround { + newCol.Options["null"] = nil + sql = append(sql, fmt.Sprintf(`ALTER TABLE "%s" ALTER COLUMN "%s" SET NOT NULL;COMMIT TRANSACTION;BEGIN TRANSACTION;`, t.Name, newCol.Name)) + } + + return strings.Join(sql, "\n"), nil }) if err != nil { @@ -146,7 +166,7 @@ func (p *Cockroach) AddColumn(t fizz.Table) (string, error) { c := t.Columns[0] s := fmt.Sprintf("ALTER TABLE \"%s\" ADD COLUMN %s;COMMIT TRANSACTION;BEGIN TRANSACTION;", t.Name, p.buildAddColumn(c)) - //Update schema cache if we can + // Update schema cache if we can tableInfo, err := p.Schema.TableInfo(t.Name) if err == nil { found := false @@ -362,9 +382,34 @@ func (p *Cockroach) withTempColumn(tableName string, column string, fn func(fizz return "", err1 } + var sql []string + var recreateIndexes []fizz.Index + for _, i := range table.Indexes { + var found bool + + for _, ic := range i.Columns { + if ic == column { + found = true + break + } + } + + if found { + s, err := p.DropIndex(fizz.Table{ + Name: table.Name, + Indexes: []fizz.Index{i}, + }) + if err != nil { + return "", err + } + sql = append(sql, s) + recreateIndexes = append(recreateIndexes, i) + } + } + tempCol := fmt.Sprintf("_%s_tmp", column) - sql := []string{fmt.Sprintf("ALTER TABLE \"%s\" RENAME COLUMN \"%s\" TO \"%s\";COMMIT TRANSACTION;BEGIN TRANSACTION;", tableName, column, tempCol)} + sql = append(sql, fmt.Sprintf("ALTER TABLE \"%s\" RENAME COLUMN \"%s\" TO \"%s\";COMMIT TRANSACTION;BEGIN TRANSACTION;", tableName, column, tempCol)) s, err := fn(*table, *col, tempCol) if err != nil { @@ -372,6 +417,17 @@ func (p *Cockroach) withTempColumn(tableName string, column string, fn func(fizz } sql = append(sql, s, fmt.Sprintf("ALTER TABLE \"%s\" DROP COLUMN \"%s\";COMMIT TRANSACTION;BEGIN TRANSACTION;", tableName, tempCol)) + for _, i := range recreateIndexes { + s, err := p.AddIndex(fizz.Table{ + Name: table.Name, + Indexes: []fizz.Index{i}, + }) + if err != nil { + return "", err + } + sql = append(sql, s) + } + return strings.Join(sql, "\n"), nil } diff --git a/translators/cockroach_meta.go b/translators/cockroach_meta.go index 2054c111..59f4502a 100644 --- a/translators/cockroach_meta.go +++ b/translators/cockroach_meta.go @@ -138,7 +138,7 @@ func (p *cockroachSchema) buildTableIndexes(t *fizz.Table, db *sql.DB) error { Columns: []string{}, } - prag = fmt.Sprintf("SELECT column_name as name, direction FROM information_schema.statistics where index_name = '%s';", i.Name) + prag = fmt.Sprintf("SELECT column_name as name, direction FROM information_schema.statistics where index_name = '%s' and implicit = 'NO';", i.Name) iires, err := db.Query(prag) if err != nil { return err diff --git a/translators/sqlite.go b/translators/sqlite.go index a9ca51f1..76a31af3 100644 --- a/translators/sqlite.go +++ b/translators/sqlite.go @@ -115,26 +115,27 @@ func (p *SQLite) ChangeColumn(t fizz.Table) (string, error) { } sql := []string{} - s, err := p.withTempTable(t.Name, func(tempTable fizz.Table) (string, error) { - var indices []string - for _, i := range tableInfo.Indexes { - s, err := p.DropIndex(fizz.Table{ - Name: tableInfo.Name, - Indexes: []fizz.Index{i}, - }) - if err != nil { - return "", err - } - indices = append(indices, s) - } - createTableSQL, err := p.CreateTable(*tableInfo) + var copyIndexes = make([]fizz.Index, len(tableInfo.Indexes)) + for k, i := range tableInfo.Indexes { + s, err := p.DropIndex(fizz.Table{ + Name: tableInfo.Name, + Indexes: []fizz.Index{i}, + }) if err != nil { return "", err } + sql = append(sql, s) + copyIndexes[k] = i + } + tableInfo.Indexes = copyIndexes // We need to recreate those - ins := fmt.Sprintf("INSERT INTO \"%s\" (%s) SELECT %s FROM \"%s\";", t.Name, strings.Join(tableInfo.ColumnNames(), ", "), strings.Join(tableInfo.ColumnNames(), ", "), tempTable.Name) - return strings.Join(append(indices, createTableSQL, ins), "\n"), nil + // We do not need to use withForeignKeyPreservingTempTable here because this will not touch any foreign keys! + s, err := p.withForeignKeyPreservingTempTable(*tableInfo, t.Name, func(newTable fizz.Table, tableName string) (string, error) { + if t.Columns[0].Name == "slug" { + fmt.Print("asdf") + } + return fmt.Sprintf("INSERT INTO \"%s\" (%s) SELECT %s FROM \"%s\";", newTable.Name, strings.Join(newTable.ColumnNames(), ", "), strings.Join(newTable.ColumnNames(), ", "), tableName), nil }) if err != nil { @@ -208,15 +209,8 @@ func (p *SQLite) DropColumn(t fizz.Table) (string, error) { } tableInfo.ForeignKeys = newForeignKeys - s, err := p.withTempTable(t.Name, func(tempTable fizz.Table) (string, error) { - createTableSQL, err := p.CreateTable(*tableInfo) - if err != nil { - return "", err - } - - s := fmt.Sprintf("INSERT INTO \"%s\" (%s) SELECT %s FROM \"%s\";", tableInfo.Name, strings.Join(tableInfo.ColumnNames(), ", "), strings.Join(tableInfo.ColumnNames(), ", "), tempTable.Name) - - return strings.Join([]string{createTableSQL, s}, "\n"), nil + s, err := p.withForeignKeyPreservingTempTable(*tableInfo, t.Name, func(newTable fizz.Table, tableName string) (string, error) { + return fmt.Sprintf("INSERT INTO \"%s\" (%s) SELECT %s FROM \"%s\";\n", newTable.Name, strings.Join(newTable.ColumnNames(), ", "), strings.Join(newTable.ColumnNames(), ", "), tableName), nil }) if err != nil { @@ -336,18 +330,52 @@ func (p *SQLite) DropForeignKey(t fizz.Table) (string, error) { func (p *SQLite) withTempTable(table string, fn func(fizz.Table) (string, error)) (string, error) { tempTable := fizz.Table{Name: fmt.Sprintf("_%s_tmp", table)} - sql := []string{ - fmt.Sprintf("ALTER TABLE \"%s\" RENAME TO \"%s\";", table, tempTable.Name), - } s, err := fn(tempTable) if err != nil { return "", err } + + sql := []string{ + fmt.Sprintf("ALTER TABLE \"%s\" RENAME TO \"%s\";", table, tempTable.Name), + } + sql = append(sql, s, fmt.Sprintf("DROP TABLE \"%s\";", tempTable.Name)) return strings.Join(sql, "\n"), nil } +// withForeignKeyPreservingTempTable create a new temporary table, copies all the contents from the old table over to the new +// table, removes the old table, and then renames the temporary table to the original table name. This +// preserves foreign key constraint because because SQLite does not drop foreign keys when their reference table +// is deleted. It only removes any columns referencing data in the deleted table. [1] +// +// [1] https://sqlite.org/lang_droptable.html +func (p *SQLite) withForeignKeyPreservingTempTable(newTable fizz.Table, tableName string, fn func(newTable fizz.Table, tableName string) (string, error)) (string, error) { + var sql []string + + newTable.Name = fmt.Sprintf("_%s_tmp", tableName) + defer func() { + newTable.Name = tableName + }() + + createTableSQL, err := p.CreateTable(newTable) + if err != nil { + return "", err + } + + callbackSQL, err := fn(newTable, tableName) + if err != nil { + return "", err + } + + return strings.Join(append(sql, + createTableSQL, + callbackSQL, + fmt.Sprintf("DROP TABLE \"%s\";", tableName), + fmt.Sprintf("ALTER TABLE \"%s\" RENAME TO \"%s\";", newTable.Name, tableName), + ), "\n"), nil +} + func (p *SQLite) buildColumn(c fizz.Column) string { s := fmt.Sprintf("\"%s\" %s", c.Name, p.colType(c)) if c.Options["null"] == nil { diff --git a/translators/sqlite_meta.go b/translators/sqlite_meta.go index a8625b44..75edc4a7 100644 --- a/translators/sqlite_meta.go +++ b/translators/sqlite_meta.go @@ -3,6 +3,7 @@ package translators import ( "database/sql" "fmt" + "regexp" "strings" "github.com/gobuffalo/fizz" @@ -170,6 +171,16 @@ func (p *sqliteSchema) buildTableIndexes(t *fizz.Table, db *sql.DB) error { return nil } +var tmpTable = regexp.MustCompile("^_(.*)_tmp$") + +func canonicalizeSQLiteTable(table string) string { + matches := tmpTable.FindAllStringSubmatch(table, 1) + if len(matches) == 1 && len(matches[0]) == 2 { + return matches[0][1] + } + return table +} + func (p *sqliteSchema) buildTableForeignKeyIndexes(t *fizz.Table, db *sql.DB) error { // This ignores all internal SQLite keys which are prefixed with `sqlite_` as explained here: // https://www.sqlite.org/fileformat2.html#intschema @@ -200,7 +211,7 @@ func (p *sqliteSchema) buildTableForeignKeyIndexes(t *fizz.Table, db *sql.DB) er i := fizz.ForeignKey{ Column: li.From, References: fizz.ForeignKeyRef{ - Table: li.Table, + Table: canonicalizeSQLiteTable(li.Table), Columns: []string{li.To}, }, Options: options, diff --git a/translators/sqlite_meta_test.go b/translators/sqlite_meta_test.go new file mode 100644 index 00000000..933a942f --- /dev/null +++ b/translators/sqlite_meta_test.go @@ -0,0 +1,15 @@ +package translators + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestCanonicalizeSQLiteTable(t *testing.T) { + assert.Equal(t, "e2e_users", canonicalizeSQLiteTable("_e2e_users_tmp")) + assert.Equal(t, "e2e_users_tmp", canonicalizeSQLiteTable("_e2e_users_tmp_tmp")) + assert.Equal(t, "e2e_users_tmp", canonicalizeSQLiteTable("e2e_users_tmp")) + assert.Equal(t, "_e2e_users_tm", canonicalizeSQLiteTable("_e2e_users_tm")) + assert.Equal(t, "_e2e_users_tmp_", canonicalizeSQLiteTable("_e2e_users_tmp_")) +} diff --git a/translators/sqlite_test.go b/translators/sqlite_test.go index 8d04c1a1..6ac738b9 100644 --- a/translators/sqlite_test.go +++ b/translators/sqlite_test.go @@ -174,14 +174,14 @@ func (p *SQLiteSuite) Test_SQLite_RenameTable_NotEnoughValues() { func (p *SQLiteSuite) Test_SQLite_ChangeColumn() { r := p.Require() - ddl := `ALTER TABLE "users" RENAME TO "_users_tmp"; -CREATE TABLE "users" ( + ddl := `CREATE TABLE "_users_tmp" ( "id" INTEGER PRIMARY KEY AUTOINCREMENT, "created_at" TEXT NOT NULL DEFAULT 'foo', "updated_at" DATETIME NOT NULL ); -INSERT INTO "users" (id, created_at, updated_at) SELECT id, created_at, updated_at FROM "_users_tmp"; -DROP TABLE "_users_tmp";` +INSERT INTO "_users_tmp" (id, created_at, updated_at) SELECT id, created_at, updated_at FROM "users"; +DROP TABLE "users"; +ALTER TABLE "_users_tmp" RENAME TO "users";` schema.schema["users"] = &fizz.Table{ Name: "users", @@ -210,13 +210,14 @@ func (p *SQLiteSuite) Test_SQLite_AddColumn() { func (p *SQLiteSuite) Test_SQLite_DropColumn() { r := p.Require() - ddl := `ALTER TABLE "users" RENAME TO "_users_tmp"; -CREATE TABLE "users" ( + ddl := `CREATE TABLE "_users_tmp" ( "id" INTEGER PRIMARY KEY AUTOINCREMENT, "updated_at" DATETIME NOT NULL ); -INSERT INTO "users" (id, updated_at) SELECT id, updated_at FROM "_users_tmp"; -DROP TABLE "_users_tmp";` +INSERT INTO "_users_tmp" (id, updated_at) SELECT id, updated_at FROM "users"; + +DROP TABLE "users"; +ALTER TABLE "_users_tmp" RENAME TO "users";` schema.schema["users"] = &fizz.Table{ Name: "users", @@ -363,16 +364,17 @@ FOREIGN KEY (user_id) REFERENCES users (uuid) ON DELETE cascade );`, res) res, _ = fizz.AString(`drop_column("user_notes","notes")`, sqt) - r.Equal(`ALTER TABLE "user_notes" RENAME TO "_user_notes_tmp"; -CREATE TABLE "user_notes" ( + r.Equal(`CREATE TABLE "_user_notes_tmp" ( "uuid" TEXT PRIMARY KEY, "user_id" char(36) NOT NULL, "created_at" DATETIME NOT NULL, "updated_at" DATETIME NOT NULL, FOREIGN KEY (user_id) REFERENCES users (uuid) ON DELETE cascade ); -INSERT INTO "user_notes" (uuid, user_id, created_at, updated_at) SELECT uuid, user_id, created_at, updated_at FROM "_user_notes_tmp"; -DROP TABLE "_user_notes_tmp";`, res) +INSERT INTO "_user_notes_tmp" (uuid, user_id, created_at, updated_at) SELECT uuid, user_id, created_at, updated_at FROM "user_notes"; + +DROP TABLE "user_notes"; +ALTER TABLE "_user_notes_tmp" RENAME TO "user_notes";`, res) res, _ = fizz.AString(`rename_table("users","user_accounts")`, sqt) r.Equal(`ALTER TABLE "users" RENAME TO "user_accounts";`, res)