diff --git a/Makefile b/Makefile index 0250c8db..54f00e2c 100644 --- a/Makefile +++ b/Makefile @@ -1,58 +1,23 @@ -TAGS ?= "sqlite" -GO_BIN ?= "go" +TAGS ?= sqlite +GO_BIN ?= go install: $(GO_BIN) install -tags ${TAGS} -v . - make tidy tidy: -ifeq ($(GO111MODULE),on) $(GO_BIN) mod tidy -else - echo skipping go mod tidy -endif - -deps: - $(GO_BIN) get -tags ${TAGS} -t ./... - make tidy build: $(GO_BIN) build -v . - make tidy test: - ./test.sh - make tidy - -ci-deps: - $(GO_BIN) get -tags ${TAGS} -t ./... - -ci-test: - $(GO_BIN) test -tags ${TAGS} -race ./... + ./test.sh -cover -v lint: go get github.com/golangci/golangci-lint/cmd/golangci-lint golangci-lint run --enable-all - make tidy update: -ifeq ($(GO111MODULE),on) rm go.* - $(GO_BIN) mod init - $(GO_BIN) mod tidy -else - $(GO_BIN) get -u -tags ${TAGS} -endif - make test - make install - make tidy - -release-test: - $(GO_BIN) test -tags ${TAGS} -race ./... - make tidy - -release: - $(GO_BIN) get github.com/gobuffalo/release - make tidy - release -y -f version.go --skip-packr - make tidy \ No newline at end of file + $(GO_BIN) mod init github.com/gobuffalo/fizz + $(GO_BIN) mod tidy --go=1.16 diff --git a/README.md b/README.md index 8898f66a..68a232e7 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,28 @@ # Fizz [![Actions Status](https://github.com/gobuffalo/fizz/workflows/Tests/badge.svg)](https://github.com/gobuffalo/fizz/actions) -[![GoDoc](https://godoc.org/github.com/gobuffalo/fizz?status.svg)](https://godoc.org/github.com/gobuffalo/fizz) +[![Go Reference](https://pkg.go.dev/badge/github.com/gobuffalo/fizz.svg)](https://pkg.go.dev/github.com/gobuffalo/fizz) A Common DSL for Migrating Databases -## Create a Table + +## Supported Database Engines + +Fizz supports minimum supported version of all supported database engines. +Currently, the following database engines are officially supported. (Since +Fizz is used with the migration feature of Pop, supported databases and the +versions are correlated with Pop.) + +* PostgreSQL 10 +* MySQL 5.7 / MariaDB 10.3 +* SQLite3 3.22 +* CockroachDB v21.1 +* MSSQL 2017 (not fully supported) + + +## Usage + +### Create a Table ``` javascript create_table("users") { @@ -28,7 +45,7 @@ create_table("todos") { } ``` -The `id` column don't have to be an integer. For instance, your can use an [`UUID`](https://github.com/gobuffalo/uuid) type instead: +The `id` column don't have to be an integer. For instance, your can use an UUID type instead: ```javascript create_table("users") { @@ -75,19 +92,19 @@ create_table("user_privileges") { Please note that the `t.PrimaryKey` statement MUST be after the columns definitions. -## Drop a Table +### Drop a Table ``` javascript drop_table("table_name") ``` -## Rename a Table +### Rename a Table ``` javascript rename_table("old_table_name", "new_table_name") ``` -## Add a Column +### Add a Column ``` javascript add_column("table_name", "column_name", "string", {}) @@ -95,69 +112,69 @@ add_column("table_name", "column_name", "string", {}) See [above](#column-info) for more details on column types and options. -## Alter a column +### Alter a column ``` javascript change_column("table_name", "column_name", "string", {}) ``` -## Rename a Column +### Rename a Column ``` javascript rename_column("table_name", "old_column_name", "new_column_name") ``` -## Drop a Column +### Drop a Column ``` javascript drop_column("table_name", "column_name") ``` -## Add an Index +### Add an Index #### Supported Options: * `name` - This defaults to `table_name_column_name_idx` * `unique` -### Simple Index: +#### Simple Index: ``` javascript add_index("table_name", "column_name", {}) ``` -### Multi-Column Index: +#### Multi-Column Index: ``` javascript add_index("table_name", ["column_1", "column_2"], {}) ``` -### Unique Index: +#### Unique Index: ``` javascript add_index("table_name", "column_name", {"unique": true}) ``` -### Index Names: +#### Index Names: ``` javascript add_index("table_name", "column_name", {}) # name => table_name_column_name_idx add_index("table_name", "column_name", {"name": "custom_index_name"}) ``` -## Rename an Index +### Rename an Index ``` javascript rename_index("table_name", "old_index_name", "new_index_name") ``` -## Drop an Index +### Drop an Index ``` javascript drop_index("table_name", "index_name") ``` -## Add a Foreign Key +### Add a Foreign Key ```javascript add_foreign_key("table_name", "field", {"ref_table_name": ["ref_column"]}, { @@ -176,7 +193,7 @@ add_foreign_key("table_name", "field", {"ref_table_name": ["ref_column"]}, { **Note:** `on_update` and `on_delete` are not supported on CockroachDB yet. -## Drop a Foreign Key +### Drop a Foreign Key ```javascript drop_foreign_key("table_name", "fk_name", {"if_exists": true}) @@ -187,13 +204,13 @@ drop_foreign_key("table_name", "fk_name", {"if_exists": true}) * `if_exists` - Adds `IF EXISTS` condition -## Raw SQL +### Raw SQL ``` javascript sql("select * from users;") ``` -## Execute an External Command +### Execute an External Command Sometimes during a migration you need to shell out to an external command. diff --git a/docker-compose.yml b/docker-compose.yml index 6e491d48..8a4ff6d1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,32 +8,53 @@ services: - MYSQL_DATABASE=pop_test - MYSQL_USER=pop - MYSQL_PASSWORD=pop - volumes: - - ./sql:/docker-entrypoint-initdb.d + #volumes: + #- ./_vol/mysql:/docker-entrypoint-initdb.d ports: - - "3306:3306" + - "3307:3306" + healthcheck: + test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"] + interval: 5s + timeout: 5s + retries: 10 + start_period: 3s + postgres: - image: postgres:9.6 + image: postgres:10 environment: - POSTGRES_DB=pop_test - POSTGRES_PASSWORD=postgres ports: - - "5432:5432" - volumes: - - ./sqldumps:/docker-entrypoint-initdb.d + - "5433:5432" + #volumes: + #- ./_vol/postgres:/docker-entrypoint-initdb.d + healthcheck: + test: ["CMD", "pg_isready"] + interval: 5s + timeout: 5s + retries: 10 + start_period: 3s + cockroach: - image: cockroachdb/cockroach:v19.2.10 + image: cockroachdb/cockroach:latest-v21.1 ports: - - "26257:26257" - - "8080:8080" - volumes: - - "./cockroach-data/roach1:/cockroach/cockroach-data" - command: start --insecure - mssqlserver: - image: "microsoft/mssql-server-linux" - environment: - - SA_PASSWORD=Tt@12345678 - - MSSQLSERVER_PASSWORD=Tt@12345678 - - ACCEPT_EULA=Y - ports: - - "1433:1433" + - "26258:26257" + - "8081:8080" + #volumes: + #- ./_vol/cockroach:/cockroach/cockroach-data + command: start-single-node --insecure + healthcheck: + test: ["CMD", "curl", "http://localhost:8080/health"] + interval: 5s + timeout: 5s + retries: 10 + start_period: 3s + +# mssqlserver: +# image: "microsoft/mssql-server-linux" +# environment: +# - SA_PASSWORD=Tt@12345678 +# - MSSQLSERVER_PASSWORD=Tt@12345678 +# - ACCEPT_EULA=Y +# ports: +# - "1433:1433" diff --git a/test.sh b/test.sh index 34cccda1..8e72c3df 100755 --- a/test.sh +++ b/test.sh @@ -1,43 +1,50 @@ #!/bin/bash + set -e -clear -verbose="" +# NOTE: See also docker-compose.yml and database.yml to configure database +# properties. +export MYSQL_PORT=3307 +export COCKROACH_PORT=26258 -echo $@ +COMPOSE=docker-compose +which docker-compose || COMPOSE="docker compose" -if [[ "$@" == "-v" ]] -then - verbose="-v" -fi +args=$@ function cleanup { echo "Cleanup resources..." - docker-compose down - find ./sql_scripts/sqlite -name *.sqlite* -delete || true + $COMPOSE down + docker volume prune -f + find ./tmp -name *.sqlite* -delete || true } # defer cleanup, so it will be executed even after premature exit trap cleanup EXIT -docker-compose up -d -sleep 10 # Ensure mysql is online - -go install -tags sqlite github.com/gobuffalo/pop/v6/soda@latest - function test { - echo "!!! Testing $1" export SODA_DIALECT=$1 + + echo "" + echo "######################################################################" + echo "### Running unit tests for $SODA_DIALECT" soda drop -e $SODA_DIALECT soda create -e $SODA_DIALECT soda migrate -e $SODA_DIALECT -p ./testdata/migrations - go test -tags sqlite -count=1 $verbose $(go list ./... | grep -v /vendor/) - echo "!!! Resetting $1" + go test -tags sqlite -count=1 $args ./... + + echo "" + echo "######################################################################" + echo "### Running e2e tests for $1" soda drop -e $SODA_DIALECT soda create -e $SODA_DIALECT - echo "!!! Running e2e tests $1" - cd testdata/e2e; go test -tags sqlite,e2e -count=1 $verbose ./...; cd .. + pushd testdata/e2e; go test -tags sqlite,e2e -count=1 $args ./...; popd } + +$COMPOSE up --wait + +go install -tags sqlite github.com/gobuffalo/pop/v6/soda@latest + test "sqlite" test "postgres" test "cockroach" diff --git a/testdata/e2e/fixtures/cockroach/down/0.sql b/testdata/e2e/fixtures/cockroach/down/0.sql index 4e370dec..cc9c77a9 100644 --- a/testdata/e2e/fixtures/cockroach/down/0.sql +++ b/testdata/e2e/fixtures/cockroach/down/0.sql @@ -1,5 +1,11 @@ -CREATE TABLE schema_migration ( +-- # 1 column +-- # row 1 +-- ## 269 +CREATE TABLE public.schema_migration ( version VARCHAR(14) NOT NULL, + rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), + CONSTRAINT "primary" PRIMARY KEY (rowid ASC), UNIQUE INDEX schema_migration_version_idx (version ASC), FAMILY "primary" (version, rowid) ); +-- # 1 row diff --git a/testdata/e2e/fixtures/cockroach/down/1.sql b/testdata/e2e/fixtures/cockroach/down/1.sql index 6d7a4713..1066f535 100644 --- a/testdata/e2e/fixtures/cockroach/down/1.sql +++ b/testdata/e2e/fixtures/cockroach/down/1.sql @@ -1,4 +1,16 @@ -CREATE TABLE e2e_users ( +-- # 1 column +-- # row 1 +-- ## 269 +CREATE TABLE public.schema_migration ( + version VARCHAR(14) NOT NULL, + rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), + CONSTRAINT "primary" PRIMARY KEY (rowid ASC), + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); +-- # row 2 +-- ## 247 +CREATE TABLE public.e2e_users ( id UUID NOT NULL, created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, @@ -6,9 +18,4 @@ CREATE TABLE e2e_users ( CONSTRAINT "primary" PRIMARY KEY (id ASC), FAMILY "primary" (id, created_at, updated_at, username) ); - -CREATE TABLE schema_migration ( - version VARCHAR(14) NOT NULL, - UNIQUE INDEX schema_migration_version_idx (version ASC), - FAMILY "primary" (version, rowid) -); +-- # 2 rows diff --git a/testdata/e2e/fixtures/cockroach/down/10.sql b/testdata/e2e/fixtures/cockroach/down/10.sql index ab6d1891..e7c4546e 100644 --- a/testdata/e2e/fixtures/cockroach/down/10.sql +++ b/testdata/e2e/fixtures/cockroach/down/10.sql @@ -1,30 +1,41 @@ -CREATE TABLE e2e_users ( +-- # 1 column +-- # row 1 +-- ## 269 +CREATE TABLE public.schema_migration ( + version VARCHAR(14) NOT NULL, + rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), + CONSTRAINT "primary" PRIMARY KEY (rowid ASC), + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); +-- # row 2 +-- ## 208 +CREATE TABLE public.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 ( +-- # row 3 +-- ## 352 +CREATE TABLE public.e2e_user_posts ( id UUID NOT NULL, content VARCHAR(255) NOT NULL DEFAULT '':::STRING, user_id UUID NOT NULL, 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, content, user_id, 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; +-- # row 4 +-- ## 152 +ALTER TABLE public.e2e_user_posts ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES public.e2e_users(id) ON DELETE CASCADE; +-- # row 5 +-- ## 115 +-- Validate foreign key constraints. These can fail if there was unvalidated data during the SHOW CREATE ALL TABLES +-- # row 6 +-- ## 85 +ALTER TABLE public.e2e_user_posts VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; +-- # 6 rows diff --git a/testdata/e2e/fixtures/cockroach/down/11.sql b/testdata/e2e/fixtures/cockroach/down/11.sql index 7028d77c..434281ad 100644 --- a/testdata/e2e/fixtures/cockroach/down/11.sql +++ b/testdata/e2e/fixtures/cockroach/down/11.sql @@ -1,30 +1,41 @@ -CREATE TABLE e2e_users ( +-- # 1 column +-- # row 1 +-- ## 269 +CREATE TABLE public.schema_migration ( + version VARCHAR(14) NOT NULL, + rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), + CONSTRAINT "primary" PRIMARY KEY (rowid ASC), + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); +-- # row 2 +-- ## 208 +CREATE TABLE public.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 ( +-- # row 3 +-- ## 352 +CREATE TABLE public.e2e_user_posts ( id UUID NOT NULL, content VARCHAR(255) NOT NULL DEFAULT '':::STRING, slug VARCHAR(32) NOT NULL, user_id UUID NOT NULL, CONSTRAINT "primary" PRIMARY KEY (id ASC), UNIQUE INDEX e2e_user_notes_slug_idx (slug 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, content, slug, user_id) ); - -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; +-- # row 4 +-- ## 152 +ALTER TABLE public.e2e_user_posts ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES public.e2e_users(id) ON DELETE CASCADE; +-- # row 5 +-- ## 115 +-- Validate foreign key constraints. These can fail if there was unvalidated data during the SHOW CREATE ALL TABLES +-- # row 6 +-- ## 85 +ALTER TABLE public.e2e_user_posts VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; +-- # 6 rows diff --git a/testdata/e2e/fixtures/cockroach/down/12.sql b/testdata/e2e/fixtures/cockroach/down/12.sql index f0663c77..16d66ece 100644 --- a/testdata/e2e/fixtures/cockroach/down/12.sql +++ b/testdata/e2e/fixtures/cockroach/down/12.sql @@ -1,30 +1,41 @@ -CREATE TABLE e2e_authors ( +-- # 1 column +-- # row 1 +-- ## 269 +CREATE TABLE public.schema_migration ( + version VARCHAR(14) NOT NULL, + rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), + CONSTRAINT "primary" PRIMARY KEY (rowid ASC), + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); +-- # row 2 +-- ## 210 +CREATE TABLE public.e2e_authors ( 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 ( +-- # row 3 +-- ## 352 +CREATE TABLE public.e2e_user_posts ( id UUID NOT NULL, content VARCHAR(255) NOT NULL DEFAULT '':::STRING, slug VARCHAR(32) NOT NULL, user_id UUID NOT NULL, CONSTRAINT "primary" PRIMARY KEY (id ASC), UNIQUE INDEX e2e_user_notes_slug_idx (slug 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, content, slug, user_id) ); - -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_authors(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; +-- # row 4 +-- ## 154 +ALTER TABLE public.e2e_user_posts ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES public.e2e_authors(id) ON DELETE CASCADE; +-- # row 5 +-- ## 115 +-- Validate foreign key constraints. These can fail if there was unvalidated data during the SHOW CREATE ALL TABLES +-- # row 6 +-- ## 85 +ALTER TABLE public.e2e_user_posts VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; +-- # 6 rows diff --git a/testdata/e2e/fixtures/cockroach/down/13.sql b/testdata/e2e/fixtures/cockroach/down/13.sql index fb9dbdd9..2c5bdc0b 100644 --- a/testdata/e2e/fixtures/cockroach/down/13.sql +++ b/testdata/e2e/fixtures/cockroach/down/13.sql @@ -1,30 +1,41 @@ -CREATE TABLE e2e_authors ( +-- # 1 column +-- # row 1 +-- ## 269 +CREATE TABLE public.schema_migration ( + version VARCHAR(14) NOT NULL, + rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), + CONSTRAINT "primary" PRIMARY KEY (rowid ASC), + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); +-- # row 2 +-- ## 210 +CREATE TABLE public.e2e_authors ( 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 ( +-- # row 3 +-- ## 358 +CREATE TABLE public.e2e_user_posts ( id UUID NOT NULL, content VARCHAR(255) NOT NULL DEFAULT '':::STRING, slug VARCHAR(32) NOT NULL, author_id UUID NOT NULL, CONSTRAINT "primary" PRIMARY KEY (id ASC), UNIQUE INDEX e2e_user_notes_slug_idx (slug ASC), - INDEX e2e_user_notes_auto_index_e2e_user_notes_e2e_users_id_fk (author_id ASC), INDEX e2e_user_notes_user_id_idx (author_id ASC), FAMILY "primary" (id, content, slug, author_id) ); - -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 (author_id) REFERENCES e2e_authors(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; +-- # row 4 +-- ## 156 +ALTER TABLE public.e2e_user_posts ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (author_id) REFERENCES public.e2e_authors(id) ON DELETE CASCADE; +-- # row 5 +-- ## 115 +-- Validate foreign key constraints. These can fail if there was unvalidated data during the SHOW CREATE ALL TABLES +-- # row 6 +-- ## 85 +ALTER TABLE public.e2e_user_posts VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; +-- # 6 rows diff --git a/testdata/e2e/fixtures/cockroach/down/14.sql b/testdata/e2e/fixtures/cockroach/down/14.sql index 3b25bca5..e55f8a38 100644 --- a/testdata/e2e/fixtures/cockroach/down/14.sql +++ b/testdata/e2e/fixtures/cockroach/down/14.sql @@ -1,12 +1,25 @@ -CREATE TABLE e2e_authors ( +-- # 1 column +-- # row 1 +-- ## 269 +CREATE TABLE public.schema_migration ( + version VARCHAR(14) NOT NULL, + rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), + CONSTRAINT "primary" PRIMARY KEY (rowid ASC), + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); +-- # row 2 +-- ## 210 +CREATE TABLE public.e2e_authors ( 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 ( +-- # row 3 +-- ## 405 +CREATE TABLE public.e2e_user_posts ( id UUID NOT NULL, content VARCHAR(255) NOT NULL DEFAULT '':::STRING, slug VARCHAR(32) NOT NULL, @@ -14,18 +27,16 @@ CREATE TABLE e2e_user_posts ( author_id UUID NULL, CONSTRAINT "primary" PRIMARY KEY (id ASC), UNIQUE INDEX e2e_user_notes_slug_idx (slug ASC), - INDEX e2e_user_notes_auto_index_e2e_user_notes_e2e_users_id_fk (author_id ASC), INDEX e2e_user_notes_user_id_idx (author_id ASC), FAMILY "primary" (id, content, slug, published, author_id) ); - -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 (author_id) REFERENCES e2e_authors(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; +-- # row 4 +-- ## 156 +ALTER TABLE public.e2e_user_posts ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (author_id) REFERENCES public.e2e_authors(id) ON DELETE CASCADE; +-- # row 5 +-- ## 115 +-- Validate foreign key constraints. These can fail if there was unvalidated data during the SHOW CREATE ALL TABLES +-- # row 6 +-- ## 85 +ALTER TABLE public.e2e_user_posts VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; +-- # 6 rows diff --git a/testdata/e2e/fixtures/cockroach/down/15.sql b/testdata/e2e/fixtures/cockroach/down/15.sql index b8c6d372..7c5c54ae 100644 --- a/testdata/e2e/fixtures/cockroach/down/15.sql +++ b/testdata/e2e/fixtures/cockroach/down/15.sql @@ -1,62 +1,82 @@ -CREATE TABLE e2e_address ( - id UUID NOT NULL, - CONSTRAINT "primary" PRIMARY KEY (id ASC), - FAMILY "primary" (id) +-- # 1 column +-- # row 1 +-- ## 269 +CREATE TABLE public.schema_migration ( + version VARCHAR(14) NOT NULL, + rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), + CONSTRAINT "primary" PRIMARY KEY (rowid ASC), + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) ); - -CREATE TABLE e2e_authors ( +-- # row 2 +-- ## 210 +CREATE TABLE public.e2e_authors ( 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_flow ( +-- # row 3 +-- ## 405 +CREATE TABLE public.e2e_user_posts ( + id UUID NOT NULL, + content VARCHAR(255) NOT NULL DEFAULT '':::STRING, + slug VARCHAR(32) NOT NULL, + published BOOL NOT NULL DEFAULT false, + author_id UUID NULL, + CONSTRAINT "primary" PRIMARY KEY (id ASC), + UNIQUE INDEX e2e_user_notes_slug_idx (slug ASC), + INDEX e2e_user_notes_user_id_idx (author_id ASC), + FAMILY "primary" (id, content, slug, published, author_id) +); +-- # row 4 +-- ## 119 +CREATE TABLE public.e2e_flow ( + id UUID NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (id ASC), + FAMILY "primary" (id) +); +-- # row 5 +-- ## 122 +CREATE TABLE public.e2e_address ( id UUID NOT NULL, CONSTRAINT "primary" PRIMARY KEY (id ASC), FAMILY "primary" (id) ); - -CREATE TABLE e2e_token ( +-- # row 6 +-- ## 492 +CREATE TABLE public.e2e_token ( id UUID NOT NULL, token VARCHAR(64) NOT NULL, e2e_address_id UUID NOT NULL, - expires_at TIMESTAMP NOT NULL DEFAULT '2000-01-01 00:00:00+00:00':::TIMESTAMP, - issued_at TIMESTAMP NOT NULL DEFAULT '2000-01-01 00:00:00+00:00':::TIMESTAMP, + expires_at TIMESTAMP NOT NULL DEFAULT '2000-01-01 00:00:00':::TIMESTAMP, + issued_at TIMESTAMP NOT NULL DEFAULT '2000-01-01 00:00:00':::TIMESTAMP, e2e_flow_id UUID NOT NULL, CONSTRAINT "primary" PRIMARY KEY (id ASC), - INDEX e2e_token_auto_index_e2e_token_e2e_address_id_fk (e2e_address_id ASC), UNIQUE INDEX e2e_token_uq_idx (token ASC), INDEX e2e_token_idx (token ASC), - INDEX e2e_token_auto_index_e2e_token_e2e_flow_id_fk (e2e_flow_id ASC), FAMILY "primary" (id, token, e2e_address_id, expires_at, issued_at, e2e_flow_id) ); - -CREATE TABLE e2e_user_posts ( - id UUID NOT NULL, - content VARCHAR(255) NOT NULL DEFAULT '':::STRING, - slug VARCHAR(32) NOT NULL, - published BOOL NOT NULL DEFAULT false, - author_id UUID NULL, - CONSTRAINT "primary" PRIMARY KEY (id ASC), - UNIQUE INDEX e2e_user_notes_slug_idx (slug ASC), - INDEX e2e_user_notes_auto_index_e2e_user_notes_e2e_users_id_fk (author_id ASC), - INDEX e2e_user_notes_user_id_idx (author_id ASC), - FAMILY "primary" (id, content, slug, published, author_id) -); - -CREATE TABLE schema_migration ( - version VARCHAR(14) NOT NULL, - UNIQUE INDEX schema_migration_version_idx (version ASC), - FAMILY "primary" (version, rowid) -); - -ALTER TABLE e2e_token ADD CONSTRAINT e2e_token_e2e_address_id_fk FOREIGN KEY (e2e_address_id) REFERENCES e2e_address(id) ON DELETE CASCADE; -ALTER TABLE e2e_token ADD CONSTRAINT e2e_token_e2e_flow_id_fk FOREIGN KEY (e2e_flow_id) REFERENCES e2e_flow(id) ON DELETE CASCADE; -ALTER TABLE e2e_user_posts ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (author_id) REFERENCES e2e_authors(id) ON DELETE CASCADE; - --- Validate foreign key constraints. These can fail if there was unvalidated data during the dump. -ALTER TABLE e2e_token VALIDATE CONSTRAINT e2e_token_e2e_address_id_fk; -ALTER TABLE e2e_token VALIDATE CONSTRAINT e2e_token_e2e_flow_id_fk; -ALTER TABLE e2e_user_posts VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; +-- # row 7 +-- ## 156 +ALTER TABLE public.e2e_user_posts ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (author_id) REFERENCES public.e2e_authors(id) ON DELETE CASCADE; +-- # row 8 +-- ## 153 +ALTER TABLE public.e2e_token ADD CONSTRAINT e2e_token_e2e_address_id_fk FOREIGN KEY (e2e_address_id) REFERENCES public.e2e_address(id) ON DELETE CASCADE; +-- # row 9 +-- ## 144 +ALTER TABLE public.e2e_token ADD CONSTRAINT e2e_token_e2e_flow_id_fk FOREIGN KEY (e2e_flow_id) REFERENCES public.e2e_flow(id) ON DELETE CASCADE; +-- # row 10 +-- ## 115 +-- Validate foreign key constraints. These can fail if there was unvalidated data during the SHOW CREATE ALL TABLES +-- # row 11 +-- ## 85 +ALTER TABLE public.e2e_user_posts VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; +-- # row 12 +-- ## 77 +ALTER TABLE public.e2e_token VALIDATE CONSTRAINT e2e_token_e2e_address_id_fk; +-- # row 13 +-- ## 74 +ALTER TABLE public.e2e_token VALIDATE CONSTRAINT e2e_token_e2e_flow_id_fk; +-- # 13 rows diff --git a/testdata/e2e/fixtures/cockroach/down/2.sql b/testdata/e2e/fixtures/cockroach/down/2.sql index 25f52369..91a85101 100644 --- a/testdata/e2e/fixtures/cockroach/down/2.sql +++ b/testdata/e2e/fixtures/cockroach/down/2.sql @@ -1,4 +1,16 @@ -CREATE TABLE e2e_users ( +-- # 1 column +-- # row 1 +-- ## 269 +CREATE TABLE public.schema_migration ( + version VARCHAR(14) NOT NULL, + rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), + CONSTRAINT "primary" PRIMARY KEY (rowid ASC), + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); +-- # row 2 +-- ## 247 +CREATE TABLE public.e2e_users ( id UUID NOT NULL, created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, @@ -6,26 +18,25 @@ CREATE TABLE e2e_users ( CONSTRAINT "primary" PRIMARY KEY (id ASC), FAMILY "primary" (id, created_at, updated_at, username) ); - -CREATE TABLE e2e_user_notes ( +-- # row 3 +-- ## 341 +CREATE TABLE public.e2e_user_notes ( id UUID NOT 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, user_id, notes, title) ); - -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_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; +-- # row 4 +-- ## 152 +ALTER TABLE public.e2e_user_notes ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES public.e2e_users(id) ON DELETE CASCADE; +-- # row 5 +-- ## 115 +-- Validate foreign key constraints. These can fail if there was unvalidated data during the SHOW CREATE ALL TABLES +-- # row 6 +-- ## 85 +ALTER TABLE public.e2e_user_notes VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; +-- # 6 rows diff --git a/testdata/e2e/fixtures/cockroach/down/3.sql b/testdata/e2e/fixtures/cockroach/down/3.sql index 07a69de4..9e064ffe 100644 --- a/testdata/e2e/fixtures/cockroach/down/3.sql +++ b/testdata/e2e/fixtures/cockroach/down/3.sql @@ -1,4 +1,16 @@ -CREATE TABLE e2e_users ( +-- # 1 column +-- # row 1 +-- ## 269 +CREATE TABLE public.schema_migration ( + version VARCHAR(14) NOT NULL, + rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), + CONSTRAINT "primary" PRIMARY KEY (rowid ASC), + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); +-- # row 2 +-- ## 247 +CREATE TABLE public.e2e_users ( id UUID NOT NULL, created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, @@ -6,24 +18,23 @@ CREATE TABLE e2e_users ( CONSTRAINT "primary" PRIMARY KEY (id ASC), FAMILY "primary" (id, created_at, updated_at, username) ); - -CREATE TABLE e2e_user_notes ( +-- # row 3 +-- ## 240 +CREATE TABLE public.e2e_user_notes ( id UUID NOT 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, user_id, 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_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; +-- # row 4 +-- ## 152 +ALTER TABLE public.e2e_user_notes ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES public.e2e_users(id) ON DELETE CASCADE; +-- # row 5 +-- ## 115 +-- Validate foreign key constraints. These can fail if there was unvalidated data during the SHOW CREATE ALL TABLES +-- # row 6 +-- ## 85 +ALTER TABLE public.e2e_user_notes VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; +-- # 6 rows diff --git a/testdata/e2e/fixtures/cockroach/down/4.sql b/testdata/e2e/fixtures/cockroach/down/4.sql index 3cd32657..1995631c 100644 --- a/testdata/e2e/fixtures/cockroach/down/4.sql +++ b/testdata/e2e/fixtures/cockroach/down/4.sql @@ -1,4 +1,16 @@ -CREATE TABLE e2e_users ( +-- # 1 column +-- # row 1 +-- ## 269 +CREATE TABLE public.schema_migration ( + version VARCHAR(14) NOT NULL, + rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), + CONSTRAINT "primary" PRIMARY KEY (rowid ASC), + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); +-- # row 2 +-- ## 247 +CREATE TABLE public.e2e_users ( id UUID NOT NULL, created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, @@ -6,26 +18,25 @@ CREATE TABLE e2e_users ( CONSTRAINT "primary" PRIMARY KEY (id ASC), FAMILY "primary" (id, created_at, updated_at, username) ); - -CREATE TABLE e2e_user_notes ( +-- # row 3 +-- ## 324 +CREATE TABLE public.e2e_user_notes ( 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_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; +-- # row 4 +-- ## 152 +ALTER TABLE public.e2e_user_notes ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES public.e2e_users(id) ON DELETE CASCADE; +-- # row 5 +-- ## 115 +-- Validate foreign key constraints. These can fail if there was unvalidated data during the SHOW CREATE ALL TABLES +-- # row 6 +-- ## 85 +ALTER TABLE public.e2e_user_notes VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; +-- # 6 rows diff --git a/testdata/e2e/fixtures/cockroach/down/5.sql b/testdata/e2e/fixtures/cockroach/down/5.sql index 3cd32657..1995631c 100644 --- a/testdata/e2e/fixtures/cockroach/down/5.sql +++ b/testdata/e2e/fixtures/cockroach/down/5.sql @@ -1,4 +1,16 @@ -CREATE TABLE e2e_users ( +-- # 1 column +-- # row 1 +-- ## 269 +CREATE TABLE public.schema_migration ( + version VARCHAR(14) NOT NULL, + rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), + CONSTRAINT "primary" PRIMARY KEY (rowid ASC), + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); +-- # row 2 +-- ## 247 +CREATE TABLE public.e2e_users ( id UUID NOT NULL, created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, @@ -6,26 +18,25 @@ CREATE TABLE e2e_users ( CONSTRAINT "primary" PRIMARY KEY (id ASC), FAMILY "primary" (id, created_at, updated_at, username) ); - -CREATE TABLE e2e_user_notes ( +-- # row 3 +-- ## 324 +CREATE TABLE public.e2e_user_notes ( 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_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; +-- # row 4 +-- ## 152 +ALTER TABLE public.e2e_user_notes ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES public.e2e_users(id) ON DELETE CASCADE; +-- # row 5 +-- ## 115 +-- Validate foreign key constraints. These can fail if there was unvalidated data during the SHOW CREATE ALL TABLES +-- # row 6 +-- ## 85 +ALTER TABLE public.e2e_user_notes VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; +-- # 6 rows diff --git a/testdata/e2e/fixtures/cockroach/down/6.sql b/testdata/e2e/fixtures/cockroach/down/6.sql index 3cd32657..1995631c 100644 --- a/testdata/e2e/fixtures/cockroach/down/6.sql +++ b/testdata/e2e/fixtures/cockroach/down/6.sql @@ -1,4 +1,16 @@ -CREATE TABLE e2e_users ( +-- # 1 column +-- # row 1 +-- ## 269 +CREATE TABLE public.schema_migration ( + version VARCHAR(14) NOT NULL, + rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), + CONSTRAINT "primary" PRIMARY KEY (rowid ASC), + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); +-- # row 2 +-- ## 247 +CREATE TABLE public.e2e_users ( id UUID NOT NULL, created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, @@ -6,26 +18,25 @@ CREATE TABLE e2e_users ( CONSTRAINT "primary" PRIMARY KEY (id ASC), FAMILY "primary" (id, created_at, updated_at, username) ); - -CREATE TABLE e2e_user_notes ( +-- # row 3 +-- ## 324 +CREATE TABLE public.e2e_user_notes ( 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_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; +-- # row 4 +-- ## 152 +ALTER TABLE public.e2e_user_notes ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES public.e2e_users(id) ON DELETE CASCADE; +-- # row 5 +-- ## 115 +-- Validate foreign key constraints. These can fail if there was unvalidated data during the SHOW CREATE ALL TABLES +-- # row 6 +-- ## 85 +ALTER TABLE public.e2e_user_notes VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; +-- # 6 rows diff --git a/testdata/e2e/fixtures/cockroach/down/7.sql b/testdata/e2e/fixtures/cockroach/down/7.sql index a3f547f1..e08c5952 100644 --- a/testdata/e2e/fixtures/cockroach/down/7.sql +++ b/testdata/e2e/fixtures/cockroach/down/7.sql @@ -1,4 +1,16 @@ -CREATE TABLE e2e_users ( +-- # 1 column +-- # row 1 +-- ## 269 +CREATE TABLE public.schema_migration ( + version VARCHAR(14) NOT NULL, + rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), + CONSTRAINT "primary" PRIMARY KEY (rowid ASC), + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); +-- # row 2 +-- ## 247 +CREATE TABLE public.e2e_users ( id UUID NOT NULL, created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, @@ -6,26 +18,25 @@ CREATE TABLE e2e_users ( CONSTRAINT "primary" PRIMARY KEY (id ASC), FAMILY "primary" (id, created_at, updated_at, username) ); - -CREATE TABLE e2e_user_posts ( +-- # row 3 +-- ## 324 +CREATE TABLE public.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; +-- # row 4 +-- ## 152 +ALTER TABLE public.e2e_user_posts ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES public.e2e_users(id) ON DELETE CASCADE; +-- # row 5 +-- ## 115 +-- Validate foreign key constraints. These can fail if there was unvalidated data during the SHOW CREATE ALL TABLES +-- # row 6 +-- ## 85 +ALTER TABLE public.e2e_user_posts VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; +-- # 6 rows diff --git a/testdata/e2e/fixtures/cockroach/down/8.sql b/testdata/e2e/fixtures/cockroach/down/8.sql index cd092333..97c5cb02 100644 --- a/testdata/e2e/fixtures/cockroach/down/8.sql +++ b/testdata/e2e/fixtures/cockroach/down/8.sql @@ -1,4 +1,16 @@ -CREATE TABLE e2e_users ( +-- # 1 column +-- # row 1 +-- ## 269 +CREATE TABLE public.schema_migration ( + version VARCHAR(14) NOT NULL, + rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), + CONSTRAINT "primary" PRIMARY KEY (rowid ASC), + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); +-- # row 2 +-- ## 247 +CREATE TABLE public.e2e_users ( id UUID NOT NULL, created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, @@ -6,26 +18,25 @@ CREATE TABLE e2e_users ( CONSTRAINT "primary" PRIMARY KEY (id ASC), FAMILY "primary" (id, created_at, updated_at, username) ); - -CREATE TABLE e2e_user_posts ( +-- # row 3 +-- ## 352 +CREATE TABLE public.e2e_user_posts ( id UUID NOT NULL, content VARCHAR(255) NOT NULL DEFAULT '':::STRING, user_id UUID NOT NULL, 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, content, user_id, 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; +-- # row 4 +-- ## 152 +ALTER TABLE public.e2e_user_posts ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES public.e2e_users(id) ON DELETE CASCADE; +-- # row 5 +-- ## 115 +-- Validate foreign key constraints. These can fail if there was unvalidated data during the SHOW CREATE ALL TABLES +-- # row 6 +-- ## 85 +ALTER TABLE public.e2e_user_posts VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; +-- # 6 rows diff --git a/testdata/e2e/fixtures/cockroach/down/9.sql b/testdata/e2e/fixtures/cockroach/down/9.sql index f0d7431c..0b52e76d 100644 --- a/testdata/e2e/fixtures/cockroach/down/9.sql +++ b/testdata/e2e/fixtures/cockroach/down/9.sql @@ -1,4 +1,16 @@ -CREATE TABLE e2e_users ( +-- # 1 column +-- # row 1 +-- ## 269 +CREATE TABLE public.schema_migration ( + version VARCHAR(14) NOT NULL, + rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), + CONSTRAINT "primary" PRIMARY KEY (rowid ASC), + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); +-- # row 2 +-- ## 239 +CREATE TABLE public.e2e_users ( id UUID NOT NULL, created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, @@ -6,26 +18,25 @@ CREATE TABLE e2e_users ( CONSTRAINT "primary" PRIMARY KEY (id ASC), FAMILY "primary" (id, created_at, updated_at, name) ); - -CREATE TABLE e2e_user_posts ( +-- # row 3 +-- ## 352 +CREATE TABLE public.e2e_user_posts ( id UUID NOT NULL, content VARCHAR(255) NOT NULL DEFAULT '':::STRING, user_id UUID NOT NULL, 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, content, user_id, 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; +-- # row 4 +-- ## 152 +ALTER TABLE public.e2e_user_posts ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES public.e2e_users(id) ON DELETE CASCADE; +-- # row 5 +-- ## 115 +-- Validate foreign key constraints. These can fail if there was unvalidated data during the SHOW CREATE ALL TABLES +-- # row 6 +-- ## 85 +ALTER TABLE public.e2e_user_posts VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; +-- # 6 rows diff --git a/testdata/e2e/fixtures/cockroach/up/0.sql b/testdata/e2e/fixtures/cockroach/up/0.sql index 094f36b7..2c9763ba 100644 --- a/testdata/e2e/fixtures/cockroach/up/0.sql +++ b/testdata/e2e/fixtures/cockroach/up/0.sql @@ -1,4 +1,16 @@ -CREATE TABLE e2e_users ( +-- # 1 column +-- # row 1 +-- ## 269 +CREATE TABLE public.schema_migration ( + version VARCHAR(14) NOT NULL, + rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), + CONSTRAINT "primary" PRIMARY KEY (rowid ASC), + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); +-- # row 2 +-- ## 247 +CREATE TABLE public.e2e_users ( id UUID NOT NULL, username VARCHAR(255) NULL, created_at TIMESTAMP NOT NULL, @@ -6,9 +18,4 @@ CREATE TABLE e2e_users ( CONSTRAINT "primary" PRIMARY KEY (id ASC), FAMILY "primary" (id, username, created_at, updated_at) ); - -CREATE TABLE schema_migration ( - version VARCHAR(14) NOT NULL, - UNIQUE INDEX schema_migration_version_idx (version ASC), - FAMILY "primary" (version, rowid) -); +-- # 2 rows diff --git a/testdata/e2e/fixtures/cockroach/up/1.sql b/testdata/e2e/fixtures/cockroach/up/1.sql index 99e6f184..4d1d0c4f 100644 --- a/testdata/e2e/fixtures/cockroach/up/1.sql +++ b/testdata/e2e/fixtures/cockroach/up/1.sql @@ -1,4 +1,16 @@ -CREATE TABLE e2e_users ( +-- # 1 column +-- # row 1 +-- ## 269 +CREATE TABLE public.schema_migration ( + version VARCHAR(14) NOT NULL, + rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), + CONSTRAINT "primary" PRIMARY KEY (rowid ASC), + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); +-- # row 2 +-- ## 247 +CREATE TABLE public.e2e_users ( id UUID NOT NULL, username VARCHAR(255) NULL, created_at TIMESTAMP NOT NULL, @@ -6,26 +18,25 @@ CREATE TABLE e2e_users ( CONSTRAINT "primary" PRIMARY KEY (id ASC), FAMILY "primary" (id, username, created_at, updated_at) ); - -CREATE TABLE e2e_user_notes ( +-- # row 3 +-- ## 341 +CREATE TABLE public.e2e_user_notes ( id UUID NOT NULL, notes VARCHAR(255) NULL, title VARCHAR(64) NOT NULL DEFAULT '':::STRING, user_id UUID 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), INDEX e2e_user_notes_title_idx (title ASC), FAMILY "primary" (id, notes, title, user_id) ); - -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_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; +-- # row 4 +-- ## 152 +ALTER TABLE public.e2e_user_notes ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES public.e2e_users(id) ON DELETE CASCADE; +-- # row 5 +-- ## 115 +-- Validate foreign key constraints. These can fail if there was unvalidated data during the SHOW CREATE ALL TABLES +-- # row 6 +-- ## 85 +ALTER TABLE public.e2e_user_notes VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; +-- # 6 rows diff --git a/testdata/e2e/fixtures/cockroach/up/10.sql b/testdata/e2e/fixtures/cockroach/up/10.sql index 5346f6ce..1ce93299 100644 --- a/testdata/e2e/fixtures/cockroach/up/10.sql +++ b/testdata/e2e/fixtures/cockroach/up/10.sql @@ -1,30 +1,41 @@ -CREATE TABLE e2e_users ( +-- # 1 column +-- # row 1 +-- ## 269 +CREATE TABLE public.schema_migration ( + version VARCHAR(14) NOT NULL, + rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), + CONSTRAINT "primary" PRIMARY KEY (rowid ASC), + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); +-- # row 2 +-- ## 208 +CREATE TABLE public.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 ( +-- # row 3 +-- ## 352 +CREATE TABLE public.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; +-- # row 4 +-- ## 152 +ALTER TABLE public.e2e_user_posts ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES public.e2e_users(id) ON DELETE CASCADE; +-- # row 5 +-- ## 115 +-- Validate foreign key constraints. These can fail if there was unvalidated data during the SHOW CREATE ALL TABLES +-- # row 6 +-- ## 85 +ALTER TABLE public.e2e_user_posts VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; +-- # 6 rows diff --git a/testdata/e2e/fixtures/cockroach/up/11.sql b/testdata/e2e/fixtures/cockroach/up/11.sql index b61522b0..046eb328 100644 --- a/testdata/e2e/fixtures/cockroach/up/11.sql +++ b/testdata/e2e/fixtures/cockroach/up/11.sql @@ -1,30 +1,41 @@ -CREATE TABLE e2e_authors ( +-- # 1 column +-- # row 1 +-- ## 269 +CREATE TABLE public.schema_migration ( + version VARCHAR(14) NOT NULL, + rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), + CONSTRAINT "primary" PRIMARY KEY (rowid ASC), + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); +-- # row 2 +-- ## 210 +CREATE TABLE public.e2e_authors ( 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 ( +-- # row 3 +-- ## 352 +CREATE TABLE public.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_authors(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; +-- # row 4 +-- ## 154 +ALTER TABLE public.e2e_user_posts ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES public.e2e_authors(id) ON DELETE CASCADE; +-- # row 5 +-- ## 115 +-- Validate foreign key constraints. These can fail if there was unvalidated data during the SHOW CREATE ALL TABLES +-- # row 6 +-- ## 85 +ALTER TABLE public.e2e_user_posts VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; +-- # 6 rows diff --git a/testdata/e2e/fixtures/cockroach/up/12.sql b/testdata/e2e/fixtures/cockroach/up/12.sql index bf9084fc..76061fa7 100644 --- a/testdata/e2e/fixtures/cockroach/up/12.sql +++ b/testdata/e2e/fixtures/cockroach/up/12.sql @@ -1,30 +1,41 @@ -CREATE TABLE e2e_authors ( +-- # 1 column +-- # row 1 +-- ## 269 +CREATE TABLE public.schema_migration ( + version VARCHAR(14) NOT NULL, + rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), + CONSTRAINT "primary" PRIMARY KEY (rowid ASC), + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); +-- # row 2 +-- ## 210 +CREATE TABLE public.e2e_authors ( 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 ( +-- # row 3 +-- ## 358 +CREATE TABLE public.e2e_user_posts ( id UUID NOT NULL, author_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 (author_id ASC), INDEX e2e_user_notes_user_id_idx (author_id ASC), UNIQUE INDEX e2e_user_notes_slug_idx (slug ASC), FAMILY "primary" (id, author_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 (author_id) REFERENCES e2e_authors(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; +-- # row 4 +-- ## 156 +ALTER TABLE public.e2e_user_posts ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (author_id) REFERENCES public.e2e_authors(id) ON DELETE CASCADE; +-- # row 5 +-- ## 115 +-- Validate foreign key constraints. These can fail if there was unvalidated data during the SHOW CREATE ALL TABLES +-- # row 6 +-- ## 85 +ALTER TABLE public.e2e_user_posts VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; +-- # 6 rows diff --git a/testdata/e2e/fixtures/cockroach/up/13.sql b/testdata/e2e/fixtures/cockroach/up/13.sql index 3b25bca5..e55f8a38 100644 --- a/testdata/e2e/fixtures/cockroach/up/13.sql +++ b/testdata/e2e/fixtures/cockroach/up/13.sql @@ -1,12 +1,25 @@ -CREATE TABLE e2e_authors ( +-- # 1 column +-- # row 1 +-- ## 269 +CREATE TABLE public.schema_migration ( + version VARCHAR(14) NOT NULL, + rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), + CONSTRAINT "primary" PRIMARY KEY (rowid ASC), + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); +-- # row 2 +-- ## 210 +CREATE TABLE public.e2e_authors ( 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 ( +-- # row 3 +-- ## 405 +CREATE TABLE public.e2e_user_posts ( id UUID NOT NULL, content VARCHAR(255) NOT NULL DEFAULT '':::STRING, slug VARCHAR(32) NOT NULL, @@ -14,18 +27,16 @@ CREATE TABLE e2e_user_posts ( author_id UUID NULL, CONSTRAINT "primary" PRIMARY KEY (id ASC), UNIQUE INDEX e2e_user_notes_slug_idx (slug ASC), - INDEX e2e_user_notes_auto_index_e2e_user_notes_e2e_users_id_fk (author_id ASC), INDEX e2e_user_notes_user_id_idx (author_id ASC), FAMILY "primary" (id, content, slug, published, author_id) ); - -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 (author_id) REFERENCES e2e_authors(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; +-- # row 4 +-- ## 156 +ALTER TABLE public.e2e_user_posts ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (author_id) REFERENCES public.e2e_authors(id) ON DELETE CASCADE; +-- # row 5 +-- ## 115 +-- Validate foreign key constraints. These can fail if there was unvalidated data during the SHOW CREATE ALL TABLES +-- # row 6 +-- ## 85 +ALTER TABLE public.e2e_user_posts VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; +-- # 6 rows diff --git a/testdata/e2e/fixtures/cockroach/up/14.sql b/testdata/e2e/fixtures/cockroach/up/14.sql index 611a3bf1..cc61db16 100644 --- a/testdata/e2e/fixtures/cockroach/up/14.sql +++ b/testdata/e2e/fixtures/cockroach/up/14.sql @@ -1,60 +1,80 @@ -CREATE TABLE e2e_address ( - id UUID NOT NULL, - CONSTRAINT "primary" PRIMARY KEY (id ASC), - FAMILY "primary" (id) +-- # 1 column +-- # row 1 +-- ## 269 +CREATE TABLE public.schema_migration ( + version VARCHAR(14) NOT NULL, + rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), + CONSTRAINT "primary" PRIMARY KEY (rowid ASC), + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) ); - -CREATE TABLE e2e_authors ( +-- # row 2 +-- ## 210 +CREATE TABLE public.e2e_authors ( 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_flow ( +-- # row 3 +-- ## 405 +CREATE TABLE public.e2e_user_posts ( + id UUID NOT NULL, + content VARCHAR(255) NOT NULL DEFAULT '':::STRING, + slug VARCHAR(32) NOT NULL, + published BOOL NOT NULL DEFAULT false, + author_id UUID NULL, + CONSTRAINT "primary" PRIMARY KEY (id ASC), + UNIQUE INDEX e2e_user_notes_slug_idx (slug ASC), + INDEX e2e_user_notes_user_id_idx (author_id ASC), + FAMILY "primary" (id, content, slug, published, author_id) +); +-- # row 4 +-- ## 119 +CREATE TABLE public.e2e_flow ( + id UUID NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (id ASC), + FAMILY "primary" (id) +); +-- # row 5 +-- ## 122 +CREATE TABLE public.e2e_address ( id UUID NOT NULL, CONSTRAINT "primary" PRIMARY KEY (id ASC), FAMILY "primary" (id) ); - -CREATE TABLE e2e_token ( +-- # row 6 +-- ## 322 +CREATE TABLE public.e2e_token ( id UUID NOT NULL, token VARCHAR(64) NOT NULL, e2e_flow_id UUID NOT NULL, e2e_address_id UUID NOT NULL, CONSTRAINT "primary" PRIMARY KEY (id ASC), - INDEX e2e_token_auto_index_e2e_token_e2e_flow_id_fk (e2e_flow_id ASC), - INDEX e2e_token_auto_index_e2e_token_e2e_address_id_fk (e2e_address_id ASC), UNIQUE INDEX e2e_token_uq_idx (token ASC), INDEX e2e_token_idx (token ASC), FAMILY "primary" (id, token, e2e_flow_id, e2e_address_id) ); - -CREATE TABLE e2e_user_posts ( - id UUID NOT NULL, - content VARCHAR(255) NOT NULL DEFAULT '':::STRING, - slug VARCHAR(32) NOT NULL, - published BOOL NOT NULL DEFAULT false, - author_id UUID NULL, - CONSTRAINT "primary" PRIMARY KEY (id ASC), - UNIQUE INDEX e2e_user_notes_slug_idx (slug ASC), - INDEX e2e_user_notes_auto_index_e2e_user_notes_e2e_users_id_fk (author_id ASC), - INDEX e2e_user_notes_user_id_idx (author_id ASC), - FAMILY "primary" (id, content, slug, published, author_id) -); - -CREATE TABLE schema_migration ( - version VARCHAR(14) NOT NULL, - UNIQUE INDEX schema_migration_version_idx (version ASC), - FAMILY "primary" (version, rowid) -); - -ALTER TABLE e2e_token ADD CONSTRAINT e2e_token_e2e_flow_id_fk FOREIGN KEY (e2e_flow_id) REFERENCES e2e_flow(id) ON DELETE CASCADE; -ALTER TABLE e2e_token ADD CONSTRAINT e2e_token_e2e_address_id_fk FOREIGN KEY (e2e_address_id) REFERENCES e2e_address(id) ON DELETE CASCADE; -ALTER TABLE e2e_user_posts ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (author_id) REFERENCES e2e_authors(id) ON DELETE CASCADE; - --- Validate foreign key constraints. These can fail if there was unvalidated data during the dump. -ALTER TABLE e2e_token VALIDATE CONSTRAINT e2e_token_e2e_flow_id_fk; -ALTER TABLE e2e_token VALIDATE CONSTRAINT e2e_token_e2e_address_id_fk; -ALTER TABLE e2e_user_posts VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; +-- # row 7 +-- ## 156 +ALTER TABLE public.e2e_user_posts ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (author_id) REFERENCES public.e2e_authors(id) ON DELETE CASCADE; +-- # row 8 +-- ## 144 +ALTER TABLE public.e2e_token ADD CONSTRAINT e2e_token_e2e_flow_id_fk FOREIGN KEY (e2e_flow_id) REFERENCES public.e2e_flow(id) ON DELETE CASCADE; +-- # row 9 +-- ## 153 +ALTER TABLE public.e2e_token ADD CONSTRAINT e2e_token_e2e_address_id_fk FOREIGN KEY (e2e_address_id) REFERENCES public.e2e_address(id) ON DELETE CASCADE; +-- # row 10 +-- ## 115 +-- Validate foreign key constraints. These can fail if there was unvalidated data during the SHOW CREATE ALL TABLES +-- # row 11 +-- ## 85 +ALTER TABLE public.e2e_user_posts VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; +-- # row 12 +-- ## 74 +ALTER TABLE public.e2e_token VALIDATE CONSTRAINT e2e_token_e2e_flow_id_fk; +-- # row 13 +-- ## 77 +ALTER TABLE public.e2e_token VALIDATE CONSTRAINT e2e_token_e2e_address_id_fk; +-- # 13 rows diff --git a/testdata/e2e/fixtures/cockroach/up/15.sql b/testdata/e2e/fixtures/cockroach/up/15.sql index 833b8b4f..d24fec17 100644 --- a/testdata/e2e/fixtures/cockroach/up/15.sql +++ b/testdata/e2e/fixtures/cockroach/up/15.sql @@ -1,62 +1,82 @@ -CREATE TABLE e2e_address ( - id UUID NOT NULL, - CONSTRAINT "primary" PRIMARY KEY (id ASC), - FAMILY "primary" (id) +-- # 1 column +-- # row 1 +-- ## 269 +CREATE TABLE public.schema_migration ( + version VARCHAR(14) NOT NULL, + rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), + CONSTRAINT "primary" PRIMARY KEY (rowid ASC), + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) ); - -CREATE TABLE e2e_authors ( +-- # row 2 +-- ## 210 +CREATE TABLE public.e2e_authors ( 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_flow ( +-- # row 3 +-- ## 405 +CREATE TABLE public.e2e_user_posts ( + id UUID NOT NULL, + content VARCHAR(255) NOT NULL DEFAULT '':::STRING, + slug VARCHAR(32) NOT NULL, + published BOOL NOT NULL DEFAULT false, + author_id UUID NULL, + CONSTRAINT "primary" PRIMARY KEY (id ASC), + UNIQUE INDEX e2e_user_notes_slug_idx (slug ASC), + INDEX e2e_user_notes_user_id_idx (author_id ASC), + FAMILY "primary" (id, content, slug, published, author_id) +); +-- # row 4 +-- ## 119 +CREATE TABLE public.e2e_flow ( + id UUID NOT NULL, + CONSTRAINT "primary" PRIMARY KEY (id ASC), + FAMILY "primary" (id) +); +-- # row 5 +-- ## 122 +CREATE TABLE public.e2e_address ( id UUID NOT NULL, CONSTRAINT "primary" PRIMARY KEY (id ASC), FAMILY "primary" (id) ); - -CREATE TABLE e2e_token ( +-- # row 6 +-- ## 488 +CREATE TABLE public.e2e_token ( id UUID NOT NULL, token VARCHAR(64) NOT NULL, e2e_address_id UUID NOT NULL, - expires_at TIMESTAMP NOT NULL DEFAULT '2000-01-01 00:00:00+00:00':::TIMESTAMP, - issued_at TIMESTAMP NOT NULL DEFAULT '2000-01-01 00:00:00+00:00':::TIMESTAMP, + expires_at TIMESTAMP NOT NULL DEFAULT '2000-01-01 00:00:00':::TIMESTAMP, + issued_at TIMESTAMP NOT NULL DEFAULT '2000-01-01 00:00:00':::TIMESTAMP, e2e_flow_id UUID NULL, CONSTRAINT "primary" PRIMARY KEY (id ASC), - INDEX e2e_token_auto_index_e2e_token_e2e_address_id_fk (e2e_address_id ASC), UNIQUE INDEX e2e_token_uq_idx (token ASC), INDEX e2e_token_idx (token ASC), - INDEX e2e_token_auto_index_e2e_token_e2e_flow_id_fk (e2e_flow_id ASC), FAMILY "primary" (id, token, e2e_address_id, expires_at, issued_at, e2e_flow_id) ); - -CREATE TABLE e2e_user_posts ( - id UUID NOT NULL, - content VARCHAR(255) NOT NULL DEFAULT '':::STRING, - slug VARCHAR(32) NOT NULL, - published BOOL NOT NULL DEFAULT false, - author_id UUID NULL, - CONSTRAINT "primary" PRIMARY KEY (id ASC), - UNIQUE INDEX e2e_user_notes_slug_idx (slug ASC), - INDEX e2e_user_notes_auto_index_e2e_user_notes_e2e_users_id_fk (author_id ASC), - INDEX e2e_user_notes_user_id_idx (author_id ASC), - FAMILY "primary" (id, content, slug, published, author_id) -); - -CREATE TABLE schema_migration ( - version VARCHAR(14) NOT NULL, - UNIQUE INDEX schema_migration_version_idx (version ASC), - FAMILY "primary" (version, rowid) -); - -ALTER TABLE e2e_token ADD CONSTRAINT e2e_token_e2e_address_id_fk FOREIGN KEY (e2e_address_id) REFERENCES e2e_address(id) ON DELETE CASCADE; -ALTER TABLE e2e_token ADD CONSTRAINT e2e_token_e2e_flow_id_fk FOREIGN KEY (e2e_flow_id) REFERENCES e2e_flow(id) ON DELETE CASCADE; -ALTER TABLE e2e_user_posts ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (author_id) REFERENCES e2e_authors(id) ON DELETE CASCADE; - --- Validate foreign key constraints. These can fail if there was unvalidated data during the dump. -ALTER TABLE e2e_token VALIDATE CONSTRAINT e2e_token_e2e_address_id_fk; -ALTER TABLE e2e_token VALIDATE CONSTRAINT e2e_token_e2e_flow_id_fk; -ALTER TABLE e2e_user_posts VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; +-- # row 7 +-- ## 156 +ALTER TABLE public.e2e_user_posts ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (author_id) REFERENCES public.e2e_authors(id) ON DELETE CASCADE; +-- # row 8 +-- ## 153 +ALTER TABLE public.e2e_token ADD CONSTRAINT e2e_token_e2e_address_id_fk FOREIGN KEY (e2e_address_id) REFERENCES public.e2e_address(id) ON DELETE CASCADE; +-- # row 9 +-- ## 144 +ALTER TABLE public.e2e_token ADD CONSTRAINT e2e_token_e2e_flow_id_fk FOREIGN KEY (e2e_flow_id) REFERENCES public.e2e_flow(id) ON DELETE CASCADE; +-- # row 10 +-- ## 115 +-- Validate foreign key constraints. These can fail if there was unvalidated data during the SHOW CREATE ALL TABLES +-- # row 11 +-- ## 85 +ALTER TABLE public.e2e_user_posts VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; +-- # row 12 +-- ## 77 +ALTER TABLE public.e2e_token VALIDATE CONSTRAINT e2e_token_e2e_address_id_fk; +-- # row 13 +-- ## 74 +ALTER TABLE public.e2e_token VALIDATE CONSTRAINT e2e_token_e2e_flow_id_fk; +-- # 13 rows diff --git a/testdata/e2e/fixtures/cockroach/up/2.sql b/testdata/e2e/fixtures/cockroach/up/2.sql index 7ac1b314..83728d31 100644 --- a/testdata/e2e/fixtures/cockroach/up/2.sql +++ b/testdata/e2e/fixtures/cockroach/up/2.sql @@ -1,4 +1,16 @@ -CREATE TABLE e2e_users ( +-- # 1 column +-- # row 1 +-- ## 269 +CREATE TABLE public.schema_migration ( + version VARCHAR(14) NOT NULL, + rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), + CONSTRAINT "primary" PRIMARY KEY (rowid ASC), + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); +-- # row 2 +-- ## 247 +CREATE TABLE public.e2e_users ( id UUID NOT NULL, username VARCHAR(255) NULL, created_at TIMESTAMP NOT NULL, @@ -6,24 +18,23 @@ CREATE TABLE e2e_users ( CONSTRAINT "primary" PRIMARY KEY (id ASC), FAMILY "primary" (id, username, created_at, updated_at) ); - -CREATE TABLE e2e_user_notes ( +-- # row 3 +-- ## 240 +CREATE TABLE public.e2e_user_notes ( id UUID NOT NULL, notes VARCHAR(255) NULL, user_id UUID 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), FAMILY "primary" (id, notes, user_id) ); - -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_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; +-- # row 4 +-- ## 152 +ALTER TABLE public.e2e_user_notes ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES public.e2e_users(id) ON DELETE CASCADE; +-- # row 5 +-- ## 115 +-- Validate foreign key constraints. These can fail if there was unvalidated data during the SHOW CREATE ALL TABLES +-- # row 6 +-- ## 85 +ALTER TABLE public.e2e_user_notes VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; +-- # 6 rows diff --git a/testdata/e2e/fixtures/cockroach/up/3.sql b/testdata/e2e/fixtures/cockroach/up/3.sql index e558dd85..cc99ebdb 100644 --- a/testdata/e2e/fixtures/cockroach/up/3.sql +++ b/testdata/e2e/fixtures/cockroach/up/3.sql @@ -1,4 +1,16 @@ -CREATE TABLE e2e_users ( +-- # 1 column +-- # row 1 +-- ## 269 +CREATE TABLE public.schema_migration ( + version VARCHAR(14) NOT NULL, + rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), + CONSTRAINT "primary" PRIMARY KEY (rowid ASC), + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); +-- # row 2 +-- ## 247 +CREATE TABLE public.e2e_users ( id UUID NOT NULL, username VARCHAR(255) NULL, created_at TIMESTAMP NOT NULL, @@ -6,25 +18,24 @@ CREATE TABLE e2e_users ( CONSTRAINT "primary" PRIMARY KEY (id ASC), FAMILY "primary" (id, username, created_at, updated_at) ); - -CREATE TABLE e2e_user_notes ( +-- # row 3 +-- ## 270 +CREATE TABLE public.e2e_user_notes ( id UUID NOT NULL, notes VARCHAR(255) NULL, user_id UUID NOT NULL, slug VARCHAR(64) 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, 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_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; +-- # row 4 +-- ## 152 +ALTER TABLE public.e2e_user_notes ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES public.e2e_users(id) ON DELETE CASCADE; +-- # row 5 +-- ## 115 +-- Validate foreign key constraints. These can fail if there was unvalidated data during the SHOW CREATE ALL TABLES +-- # row 6 +-- ## 85 +ALTER TABLE public.e2e_user_notes VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; +-- # 6 rows diff --git a/testdata/e2e/fixtures/cockroach/up/4.sql b/testdata/e2e/fixtures/cockroach/up/4.sql index e558dd85..cc99ebdb 100644 --- a/testdata/e2e/fixtures/cockroach/up/4.sql +++ b/testdata/e2e/fixtures/cockroach/up/4.sql @@ -1,4 +1,16 @@ -CREATE TABLE e2e_users ( +-- # 1 column +-- # row 1 +-- ## 269 +CREATE TABLE public.schema_migration ( + version VARCHAR(14) NOT NULL, + rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), + CONSTRAINT "primary" PRIMARY KEY (rowid ASC), + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); +-- # row 2 +-- ## 247 +CREATE TABLE public.e2e_users ( id UUID NOT NULL, username VARCHAR(255) NULL, created_at TIMESTAMP NOT NULL, @@ -6,25 +18,24 @@ CREATE TABLE e2e_users ( CONSTRAINT "primary" PRIMARY KEY (id ASC), FAMILY "primary" (id, username, created_at, updated_at) ); - -CREATE TABLE e2e_user_notes ( +-- # row 3 +-- ## 270 +CREATE TABLE public.e2e_user_notes ( id UUID NOT NULL, notes VARCHAR(255) NULL, user_id UUID NOT NULL, slug VARCHAR(64) 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, 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_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; +-- # row 4 +-- ## 152 +ALTER TABLE public.e2e_user_notes ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES public.e2e_users(id) ON DELETE CASCADE; +-- # row 5 +-- ## 115 +-- Validate foreign key constraints. These can fail if there was unvalidated data during the SHOW CREATE ALL TABLES +-- # row 6 +-- ## 85 +ALTER TABLE public.e2e_user_notes VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; +-- # 6 rows diff --git a/testdata/e2e/fixtures/cockroach/up/5.sql b/testdata/e2e/fixtures/cockroach/up/5.sql index b66869e4..0a021eae 100644 --- a/testdata/e2e/fixtures/cockroach/up/5.sql +++ b/testdata/e2e/fixtures/cockroach/up/5.sql @@ -1,4 +1,16 @@ -CREATE TABLE e2e_users ( +-- # 1 column +-- # row 1 +-- ## 269 +CREATE TABLE public.schema_migration ( + version VARCHAR(14) NOT NULL, + rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), + CONSTRAINT "primary" PRIMARY KEY (rowid ASC), + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); +-- # row 2 +-- ## 247 +CREATE TABLE public.e2e_users ( id UUID NOT NULL, username VARCHAR(255) NULL, created_at TIMESTAMP NOT NULL, @@ -6,26 +18,25 @@ CREATE TABLE e2e_users ( CONSTRAINT "primary" PRIMARY KEY (id ASC), FAMILY "primary" (id, username, created_at, updated_at) ); - -CREATE TABLE e2e_user_notes ( +-- # row 3 +-- ## 324 +CREATE TABLE public.e2e_user_notes ( id UUID NOT NULL, notes VARCHAR(255) NULL, user_id UUID NOT NULL, 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, notes, user_id, 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_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; +-- # row 4 +-- ## 152 +ALTER TABLE public.e2e_user_notes ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES public.e2e_users(id) ON DELETE CASCADE; +-- # row 5 +-- ## 115 +-- Validate foreign key constraints. These can fail if there was unvalidated data during the SHOW CREATE ALL TABLES +-- # row 6 +-- ## 85 +ALTER TABLE public.e2e_user_notes VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; +-- # 6 rows diff --git a/testdata/e2e/fixtures/cockroach/up/6.sql b/testdata/e2e/fixtures/cockroach/up/6.sql index 6b7f10b2..cb08e9f8 100644 --- a/testdata/e2e/fixtures/cockroach/up/6.sql +++ b/testdata/e2e/fixtures/cockroach/up/6.sql @@ -1,4 +1,16 @@ -CREATE TABLE e2e_users ( +-- # 1 column +-- # row 1 +-- ## 269 +CREATE TABLE public.schema_migration ( + version VARCHAR(14) NOT NULL, + rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), + CONSTRAINT "primary" PRIMARY KEY (rowid ASC), + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); +-- # row 2 +-- ## 247 +CREATE TABLE public.e2e_users ( id UUID NOT NULL, username VARCHAR(255) NULL, created_at TIMESTAMP NOT NULL, @@ -6,26 +18,25 @@ CREATE TABLE e2e_users ( CONSTRAINT "primary" PRIMARY KEY (id ASC), FAMILY "primary" (id, username, created_at, updated_at) ); - -CREATE TABLE e2e_user_posts ( +-- # row 3 +-- ## 324 +CREATE TABLE public.e2e_user_posts ( id UUID NOT NULL, notes VARCHAR(255) NULL, user_id UUID NOT NULL, 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, notes, user_id, 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; +-- # row 4 +-- ## 152 +ALTER TABLE public.e2e_user_posts ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES public.e2e_users(id) ON DELETE CASCADE; +-- # row 5 +-- ## 115 +-- Validate foreign key constraints. These can fail if there was unvalidated data during the SHOW CREATE ALL TABLES +-- # row 6 +-- ## 85 +ALTER TABLE public.e2e_user_posts VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; +-- # 6 rows diff --git a/testdata/e2e/fixtures/cockroach/up/7.sql b/testdata/e2e/fixtures/cockroach/up/7.sql index c0843a8b..9cea5c38 100644 --- a/testdata/e2e/fixtures/cockroach/up/7.sql +++ b/testdata/e2e/fixtures/cockroach/up/7.sql @@ -1,4 +1,16 @@ -CREATE TABLE e2e_users ( +-- # 1 column +-- # row 1 +-- ## 269 +CREATE TABLE public.schema_migration ( + version VARCHAR(14) NOT NULL, + rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), + CONSTRAINT "primary" PRIMARY KEY (rowid ASC), + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); +-- # row 2 +-- ## 247 +CREATE TABLE public.e2e_users ( id UUID NOT NULL, username VARCHAR(255) NULL, created_at TIMESTAMP NOT NULL, @@ -6,26 +18,25 @@ CREATE TABLE e2e_users ( CONSTRAINT "primary" PRIMARY KEY (id ASC), FAMILY "primary" (id, username, created_at, updated_at) ); - -CREATE TABLE e2e_user_posts ( +-- # row 3 +-- ## 352 +CREATE TABLE public.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; +-- # row 4 +-- ## 152 +ALTER TABLE public.e2e_user_posts ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES public.e2e_users(id) ON DELETE CASCADE; +-- # row 5 +-- ## 115 +-- Validate foreign key constraints. These can fail if there was unvalidated data during the SHOW CREATE ALL TABLES +-- # row 6 +-- ## 85 +ALTER TABLE public.e2e_user_posts VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; +-- # 6 rows diff --git a/testdata/e2e/fixtures/cockroach/up/8.sql b/testdata/e2e/fixtures/cockroach/up/8.sql index fe96793b..8746816e 100644 --- a/testdata/e2e/fixtures/cockroach/up/8.sql +++ b/testdata/e2e/fixtures/cockroach/up/8.sql @@ -1,4 +1,16 @@ -CREATE TABLE e2e_users ( +-- # 1 column +-- # row 1 +-- ## 269 +CREATE TABLE public.schema_migration ( + version VARCHAR(14) NOT NULL, + rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), + CONSTRAINT "primary" PRIMARY KEY (rowid ASC), + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); +-- # row 2 +-- ## 239 +CREATE TABLE public.e2e_users ( id UUID NOT NULL, name VARCHAR(255) NULL, created_at TIMESTAMP NOT NULL, @@ -6,26 +18,25 @@ CREATE TABLE e2e_users ( CONSTRAINT "primary" PRIMARY KEY (id ASC), FAMILY "primary" (id, name, created_at, updated_at) ); - -CREATE TABLE e2e_user_posts ( +-- # row 3 +-- ## 352 +CREATE TABLE public.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; +-- # row 4 +-- ## 152 +ALTER TABLE public.e2e_user_posts ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES public.e2e_users(id) ON DELETE CASCADE; +-- # row 5 +-- ## 115 +-- Validate foreign key constraints. These can fail if there was unvalidated data during the SHOW CREATE ALL TABLES +-- # row 6 +-- ## 85 +ALTER TABLE public.e2e_user_posts VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; +-- # 6 rows diff --git a/testdata/e2e/fixtures/cockroach/up/9.sql b/testdata/e2e/fixtures/cockroach/up/9.sql index 99fb8e71..9ca0d17c 100644 --- a/testdata/e2e/fixtures/cockroach/up/9.sql +++ b/testdata/e2e/fixtures/cockroach/up/9.sql @@ -1,30 +1,41 @@ -CREATE TABLE e2e_users ( +-- # 1 column +-- # row 1 +-- ## 269 +CREATE TABLE public.schema_migration ( + version VARCHAR(14) NOT NULL, + rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(), + CONSTRAINT "primary" PRIMARY KEY (rowid ASC), + UNIQUE INDEX schema_migration_version_idx (version ASC), + FAMILY "primary" (version, rowid) +); +-- # row 2 +-- ## 208 +CREATE TABLE public.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 ( +-- # row 3 +-- ## 352 +CREATE TABLE public.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; +-- # row 4 +-- ## 152 +ALTER TABLE public.e2e_user_posts ADD CONSTRAINT e2e_user_notes_e2e_users_id_fk FOREIGN KEY (user_id) REFERENCES public.e2e_users(id) ON DELETE CASCADE; +-- # row 5 +-- ## 115 +-- Validate foreign key constraints. These can fail if there was unvalidated data during the SHOW CREATE ALL TABLES +-- # row 6 +-- ## 85 +ALTER TABLE public.e2e_user_posts VALIDATE CONSTRAINT e2e_user_notes_e2e_users_id_fk; +-- # 6 rows