Skip to content

Commit db4b292

Browse files
authored
feat: for schema tests, try to use pg_dump (#1562)
* feat: for schema tests, try to use pg_dump * feat: use pg_dump generated schemas
1 parent 404d104 commit db4b292

File tree

4 files changed

+24
-25
lines changed

4 files changed

+24
-25
lines changed

migrations/schema-15.sql

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
--
2+
-- PostgreSQL database dump
3+
--
4+
5+
-- Dumped from database version 15.8
6+
-- Dumped by pg_dump version 15.8
7+
18
SET statement_timeout = 0;
29
SET lock_timeout = 0;
310
SET idle_in_transaction_session_timeout = 0;
@@ -1004,8 +1011,3 @@ CREATE EVENT TRIGGER pgrst_drop_watch ON sql_drop
10041011
-- PostgreSQL database dump complete
10051012
--
10061013

1007-
1008-
--
1009-
-- Dbmate schema migrations
1010-
--
1011-

migrations/schema-17.sql

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
--
2+
-- PostgreSQL database dump
3+
--
4+
5+
-- Dumped from database version 17.4
6+
-- Dumped by pg_dump version 17.4
7+
18
SET statement_timeout = 0;
29
SET lock_timeout = 0;
310
SET idle_in_transaction_session_timeout = 0;
@@ -991,8 +998,3 @@ CREATE EVENT TRIGGER pgrst_drop_watch ON sql_drop
991998
-- PostgreSQL database dump complete
992999
--
9931000

994-
995-
--
996-
-- Dbmate schema migrations
997-
--
998-

migrations/schema-orioledb-17.sql

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
--
2+
-- PostgreSQL database dump
3+
--
4+
5+
-- Dumped from database version 17.0
6+
-- Dumped by pg_dump version 17.0
7+
18
SET statement_timeout = 0;
29
SET lock_timeout = 0;
310
SET idle_in_transaction_session_timeout = 0;
@@ -1005,8 +1012,3 @@ CREATE EVENT TRIGGER pgrst_drop_watch ON sql_drop
10051012
-- PostgreSQL database dump complete
10061013
--
10071014

1008-
1009-
--
1010-
-- Dbmate schema migrations
1011-
--
1012-

nix/tools/dbmate-tool.sh.in

+3-10
Original file line numberDiff line numberDiff line change
@@ -187,17 +187,10 @@ perform_dump() {
187187
local attempt=1
188188

189189
while [ $attempt -le $max_attempts ]; do
190-
echo "Attempting dbmate dump (attempt $attempt/$max_attempts)"
190+
echo "Attempting pg_dump (attempt $attempt/$max_attempts)"
191191

192-
# Run dbmate dump
193-
if dbmate dump; then
194-
# Post-process schema.sql to remove schema_migrations INSERT statements
195-
if [ -f "db/schema.sql" ]; then
196-
# Remove INSERT INTO schema_migrations lines
197-
sed -i '/^INSERT INTO schema_migrations/d' db/schema.sql
198-
echo "Schema dump completed successfully (schema_migrations data removed)"
199-
return 0
200-
fi
192+
if "${PSQLBIN}/pg_dump" -h localhost -p "$PORTNO" -U "$PGSQL_SUPERUSER" -d postgres --schema-only --no-owner --no-privileges > "./db/schema.sql"; then
193+
return 0
201194
fi
202195

203196
echo "Dump attempt $attempt failed, waiting before retry..."

0 commit comments

Comments
 (0)