feat: allow passing extra arguments to mysqldump/pgdump & fix broken tests (mysql & postgres)
feat: allow passing extra arguments to mysqldump/pgdump & fix broken tests (mysql & postgres)
-
feat: Allow passing extra arguments to the dump command as follows: `dbmate dump extra --flag1 --flag2`` Users can specify "extra" or "e" after dump, and all the arguments following it will be passed to pgdump or mysqldump. -> I also added a test to verify this functionality We can furter allow passing extra arguments for sqlite, bigquery and clickhouse (If need be)
-
test: Fix MySQL tests using the new feature.
2026: "TLS/SSL error: self-signed certificate in certificate chain"Currently, a TLS/SSL certificate is required by default. I disable it in tests as follows: schema, err := drv.DumpSchema(db, []string{"--disable-ssl"}) This argument is added only in tests, so there are no changes for end users. -
test: Fix postgres tests against v17.6 In v17.6 postgres added
\restricted <random_token>and\unrestrict <random_token>lines so old tests could no longer pass, I changed them
Behavior remains the same. All tests pass.
Fixes: https://github.com/amacneil/dbmate/issues/678 Fixes: https://github.com/amacneil/dbmate/issues/688
@amacneil
@amacneil Can you kindly review and merge this?
Any time a PR includes "and" in the title, it's a sign that it may be doing too many things at once.
Decouple this PR into separate PRs that can be reviewed and considered independently, please.
Interface and public function changed for new feature, not to fix tests. How do you allow users to pass extra arguments if not by passing them to function/db instance?
So I add an argument for DumpSchema like so:
- DumpSchema(*sql.DB) ([]byte, error)
+ DumpSchema(*sql.DB, []string) ([]byte, error)
DB:
+ // Additional arguments for pg/mysql schema dump
+ DumpExtraArgs []string
Using dbmate as a library you can now pass additional arguments as follows:
- Pass directly to driver (as I did in mysql tests)
schema, err := drv.DumpSchema(db, []string{"--disable-ssl"})
- Using db instance:
db.DumpExtraArgs = []string{"--disable-ssl"}
db.DumpSchema()
For CLI users:
dbmate dump extra [...]
behaviour is unchanged (for cli users).
Any time a PR includes "and" in the title, it's a sign that it may be doing too many things at once.
True, BUT - I fixed mysql tests by using new feature (as I mentioned in PR message). The only thing I can decouple is postgres tests (I don't consider it a good idea for now).