Skip to content

feat: for schema tests, try to use pg_dump #1562

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

Merged
merged 2 commits into from
Apr 22, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions migrations/schema-15.sql
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -998,8 +1005,3 @@ CREATE EVENT TRIGGER pgrst_drop_watch ON sql_drop
-- PostgreSQL database dump complete
--


--
-- Dbmate schema migrations
--

12 changes: 7 additions & 5 deletions migrations/schema-17.sql
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -985,8 +992,3 @@ CREATE EVENT TRIGGER pgrst_drop_watch ON sql_drop
-- PostgreSQL database dump complete
--


--
-- Dbmate schema migrations
--

12 changes: 7 additions & 5 deletions migrations/schema-orioledb-17.sql
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -999,8 +1006,3 @@ CREATE EVENT TRIGGER pgrst_drop_watch ON sql_drop
-- PostgreSQL database dump complete
--


--
-- Dbmate schema migrations
--

13 changes: 3 additions & 10 deletions nix/tools/dbmate-tool.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -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..."
Expand Down