From be6e6c3f0c504717d06415f28559b3eb6805af0d Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Mon, 21 Apr 2025 17:04:51 -0400 Subject: [PATCH 1/2] feat: for schema tests, try to use pg_dump --- nix/tools/dbmate-tool.sh.in | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/nix/tools/dbmate-tool.sh.in b/nix/tools/dbmate-tool.sh.in index ca38f3ac1..d914c5aec 100644 --- a/nix/tools/dbmate-tool.sh.in +++ b/nix/tools/dbmate-tool.sh.in @@ -187,17 +187,10 @@ perform_dump() { local attempt=1 while [ $attempt -le $max_attempts ]; do - echo "Attempting dbmate dump (attempt $attempt/$max_attempts)" + echo "Attempting pg_dump (attempt $attempt/$max_attempts)" - # Run dbmate dump - if dbmate dump; then - # Post-process schema.sql to remove schema_migrations INSERT statements - if [ -f "db/schema.sql" ]; then - # Remove INSERT INTO schema_migrations lines - sed -i '/^INSERT INTO schema_migrations/d' db/schema.sql - echo "Schema dump completed successfully (schema_migrations data removed)" - return 0 - fi + if "${PSQLBIN}/pg_dump" -h localhost -p "$PORTNO" -U "$PGSQL_SUPERUSER" -d postgres --schema-only --no-owner --no-privileges > "./db/schema.sql"; then + return 0 fi echo "Dump attempt $attempt failed, waiting before retry..." From 86e4595b44d70d29e07038f933e286fc21a44fa9 Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Mon, 21 Apr 2025 17:11:48 -0400 Subject: [PATCH 2/2] feat: use pg_dump generated schemas --- migrations/schema-15.sql | 12 +++++++----- migrations/schema-17.sql | 12 +++++++----- migrations/schema-orioledb-17.sql | 12 +++++++----- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/migrations/schema-15.sql b/migrations/schema-15.sql index 802fbae79..750436ae1 100644 --- a/migrations/schema-15.sql +++ b/migrations/schema-15.sql @@ -1,3 +1,10 @@ +-- +-- PostgreSQL database dump +-- + +-- Dumped from database version 15.8 +-- Dumped by pg_dump version 15.8 + SET statement_timeout = 0; SET lock_timeout = 0; SET idle_in_transaction_session_timeout = 0; @@ -998,8 +1005,3 @@ CREATE EVENT TRIGGER pgrst_drop_watch ON sql_drop -- PostgreSQL database dump complete -- - --- --- Dbmate schema migrations --- - diff --git a/migrations/schema-17.sql b/migrations/schema-17.sql index eac1280b1..d727581ce 100644 --- a/migrations/schema-17.sql +++ b/migrations/schema-17.sql @@ -1,3 +1,10 @@ +-- +-- PostgreSQL database dump +-- + +-- Dumped from database version 17.4 +-- Dumped by pg_dump version 17.4 + SET statement_timeout = 0; SET lock_timeout = 0; SET idle_in_transaction_session_timeout = 0; @@ -985,8 +992,3 @@ CREATE EVENT TRIGGER pgrst_drop_watch ON sql_drop -- PostgreSQL database dump complete -- - --- --- Dbmate schema migrations --- - diff --git a/migrations/schema-orioledb-17.sql b/migrations/schema-orioledb-17.sql index 013b23d1f..62902f08a 100644 --- a/migrations/schema-orioledb-17.sql +++ b/migrations/schema-orioledb-17.sql @@ -1,3 +1,10 @@ +-- +-- PostgreSQL database dump +-- + +-- Dumped from database version 17.0 +-- Dumped by pg_dump version 17.0 + SET statement_timeout = 0; SET lock_timeout = 0; SET idle_in_transaction_session_timeout = 0; @@ -999,8 +1006,3 @@ CREATE EVENT TRIGGER pgrst_drop_watch ON sql_drop -- PostgreSQL database dump complete -- - --- --- Dbmate schema migrations --- -