Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add failing test case for drop_column #96

Merged
merged 8 commits into from
Aug 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
3 changes: 2 additions & 1 deletion internal/e2e/fixtures/cockroach/down/1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
30 changes: 30 additions & 0 deletions internal/e2e/fixtures/cockroach/down/10.sql
Original file line number Diff line number Diff line change
@@ -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;
9 changes: 5 additions & 4 deletions internal/e2e/fixtures/cockroach/down/2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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;
9 changes: 5 additions & 4 deletions internal/e2e/fixtures/cockroach/down/3.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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;
9 changes: 5 additions & 4 deletions internal/e2e/fixtures/cockroach/down/4.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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;
9 changes: 5 additions & 4 deletions internal/e2e/fixtures/cockroach/down/5.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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;
9 changes: 5 additions & 4 deletions internal/e2e/fixtures/cockroach/down/6.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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;
31 changes: 31 additions & 0 deletions internal/e2e/fixtures/cockroach/down/7.sql
Original file line number Diff line number Diff line change
@@ -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;
31 changes: 31 additions & 0 deletions internal/e2e/fixtures/cockroach/down/8.sql
Original file line number Diff line number Diff line change
@@ -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;
31 changes: 31 additions & 0 deletions internal/e2e/fixtures/cockroach/down/9.sql
Original file line number Diff line number Diff line change
@@ -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;
3 changes: 2 additions & 1 deletion internal/e2e/fixtures/cockroach/up/0.sql
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down
5 changes: 3 additions & 2 deletions internal/e2e/fixtures/cockroach/up/1.sql
Original file line number Diff line number Diff line change
@@ -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 (
Expand All @@ -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;
30 changes: 30 additions & 0 deletions internal/e2e/fixtures/cockroach/up/10.sql
Original file line number Diff line number Diff line change
@@ -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;