Clean up pg_dump output in schema and rollup#10
Conversation
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Automatically remove version headers and psql meta-commands (\restrict,
\unrestrict) from pg_dump output to ensure consistency across
environments and CI.
The following lines are now removed:
- Lines starting with '-- Dumped by pg_dump version'
- Lines starting with '\restrict <key>' and the line immediately following it
- Lines starting with '\unrestrict <key>' and the line immediately following it
This matches the behavior of the following sed command:
sed -i -e '/^-- Dumped by pg_dump version/d' -e '/^\\restrict [^[:space:]]\+/{N;d;}' -e '/^\\unrestrict [^[:space:]]\+/{N;d;}' db/schema.sql
The implementation uses a static method `PostgresAdapter::clean_pg_dump_output`
to filter the output using iterators. This method is used in both
`PostgresAdapter::dump_schema` and the `rollup` command.
Refactor database dumping logic and clean pg_dump output
1. Updated `DatabaseAdapter` trait with `dump_schema` and `dump_data`
methods, both taking an `exclude_migrations` boolean parameter.
2. Implemented these methods for `PostgresAdapter` and `SqliteAdapter`.
3. In `PostgresAdapter`, added automatic filtering of `pg_dump` output
to remove environment-specific headers and `\restrict`/`\unrestrict`
commands, ensuring consistency across environments and CI.
4. Simplified `rollup` command by using the new `DatabaseAdapter`
methods, removing manual CLI calls and conditional logic for
different databases.
5. Added unit tests for the Postgres dump cleaning logic.
aeb1958 to
8a9ca67
Compare
This change automates the cleanup of
pg_dumpoutput incrude. It introduces aclean_pg_dump_outputfunction insrc/db/postgres.rsthat uses regex to filter out environment-specific lines (like version headers and the new\restrictsecurity wrappers introduced in recent PostgreSQL versions). This logic is applied toPostgresAdapter::dump_schemaand also to the manualpg_dumpcalls insrc/commands/rollup.rs, ensuring that all schema and data dumps produced by the tool are consistent and diff-friendly. Unit tests have been added to verify the filtering logic.PR created automatically by Jules for task 17102444846717328940 started by @pksunkara