question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add option to run `pg_dump` into `migrations/schema.sql` on commit by default

See original GitHub issue

Feature description

The README currently recommends doing this yourself, and provides a straightforward example, but IMO this should be built-in and ideally enabled by default once proven out.

My thinking is that reviewing the final schema.sql should be core to the workflow of using graphile-migrate – this is an opinionated tool, and it should be okay to enforce this opinion (especially because some of its other opinions don’t work so well without it, like the fact that you can accidentally leave a rnd() function lying around). I don’t think a tool like this should be used without dumping and reviewing the schema.sql on every commit.

Ideally, any issues people have with this workflow should also be reported and fixes shared, rather than worked around in each user’s bash scripts.

Disclaimer that I am a prospective user, not an active user – this is more a suggestion than a request.

Motivating example

Breaking changes

Supporting development

I [tick all that apply]:

  • am interested in building this feature myself
  • am interested in collaborating on building this feature
  • am willing to help testing this feature before it’s released
  • am willing to write a test-driven test suite for this feature (before it exists)
  • am a Graphile sponsor ❤️ (patreon)
  • have an active support or consultancy contract with Graphile

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
rattrayalexcommented, Apr 14, 2021

I’d also be interested in being able to edit the pg_dump and having a tool (not necessarily this one) generate an editable migration file. This might be accomplishable by calling into pgadmin’s code for their “schema diff” feature: https://github.com/djrobstep/migra/issues/148

This might help get closer to the more declarative workflows developers tend to like

1reaction
benjiecommented, Apr 10, 2021

I did consider it, but I’m not sure that pg_dump is the optimal experience for all users. Some people have other equally valid strategies (for example one person has set up a series of pg_dump scripts that dump different schemas and different resources into different files), so I don’t think enforcing a particular flow (e.g. single pg_dump) is best. Further, people may want to only dump schemas that graphile migrate is used with; I know migrate users that have per-tenant custom schemas that aren’t managed via migrations that they don’t want dumped via pg_dump, so they must pass custom options. Building it in seems like decreased flexibility and greater maintenance burden; though I do think it may be worth enabling (rather than commenting) in the default gmrc.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation: 15: pg_dump - PostgreSQL
By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when...
Read more >
Active Record Migrations - Rails Edge Guides
Migrations are a feature of Active Record that allows you to evolve your database schema over time. Rather than write schema modifications in...
Read more >
migrate/README.md at main · graphile/migrate - GitHub
graphile-migrate watch Runs any un-executed committed migrations and then runs and watches the current migration, re-running it on any change. For development.
Read more >
graphile-migrate - npm
Runs any un-executed committed migrations. Does not run current.sql . For use in production and development. If --shadow is specified, migrates ...
Read more >
Migrations Page | CockroachDB Docs
Convert a schema from a PostgreSQL, MySQL, Oracle, or Microsoft SQL Server database for use with CockroachDB. · Create a new database that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found