File tree Expand file tree Collapse file tree 2 files changed +35
-4
lines changed Expand file tree Collapse file tree 2 files changed +35
-4
lines changed Original file line number Diff line number Diff line change @@ -22,3 +22,5 @@ result*
2222# IDE
2323.idea /
2424.vscode /
25+
26+ db
Original file line number Diff line number Diff line change @@ -196,8 +196,37 @@ export DATABASE_URL="postgres://$PGSQL_USER:$PGPASSWORD@localhost:$PORTNO/postgr
196196
197197ls -la " $MIGRATIONS_DIR "
198198pwd
199- dbmate --migrations-dir " $MIGRATIONS_DIR /init-scripts" up
200- " ${PSQLBIN} /psql" -v ON_ERROR_STOP=1 --no-password --no-psqlrc -U postgres -p " $PORTNO " -h localhost -c " ALTER USER supabase_admin WITH PASSWORD '$PGPASSWORD '"
199+ # First dbmate command
200+ if ! dbmate --migrations-dir " $MIGRATIONS_DIR /init-scripts" up; then
201+ echo " Error: Initial migration failed"
202+ exit 1
203+ fi
204+
205+ # Password update command
206+ if ! " ${PSQLBIN} /psql" -v ON_ERROR_STOP=1 --no-password --no-psqlrc -U postgres -p " $PORTNO " -h localhost -c " ALTER USER supabase_admin WITH PASSWORD '$PGPASSWORD '" ; then
207+ echo " Error: Failed to update supabase_admin password"
208+ exit 1
209+ fi
210+
211+ # Set up database URL
201212export DATABASE_URL=" postgres://$PGSQL_SUPERUSER :$PGPASSWORD @localhost:$PORTNO /postgres?sslmode=disable"
202- dbmate --migrations-dir " $MIGRATIONS_DIR /migrations" up
203- echo " PostgreSQL configuration completed successfully"
213+
214+ # Second dbmate command
215+ if ! dbmate --migrations-dir " $MIGRATIONS_DIR /migrations" up; then
216+ echo " Error: Final migration failed"
217+ exit 1
218+ fi
219+
220+ if [ -f " ./db/schema.sql" ]; then
221+ mv " ./db/schema.sql" " ./db/schema-$PSQL_VERSION .sql"
222+ rm -rf ./db
223+ echo " Schema file moved to ./migrations/schema-$PSQL_VERSION .sql"
224+ else
225+ echo " Warning: schema.sql file not found in ./db directory"
226+ exit 1
227+ fi
228+
229+ " ${PSQLBIN} /pg_dump" -U " $PGSQL_SUPERUSER " -p " $PORTNO " -h localhost -d postgres -s -f " ./pg-dump-schema-$PSQL_VERSION .sql"
230+
231+ # If we get here, all commands succeeded
232+ echo " PostgreSQL migration completed successfully"
You can’t perform that action at this time.
0 commit comments