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.

This is a very intriguing approach to database migrations! I like the idea of watching a single file during development.

I have a few questions:

  1. Why Javascript?

For a fast CLI tool it would appear Go or an otherwise compiled language would be a great choice. i.e. having a single binary to deal with, working with bytes of the files directly rather than converting to strings, etc… I ask not to push one choice over the other but because I am curious if this is because of some some specific plans, i.e. “this module will eventually become a part of postgraphile”.

  1. What is the shadow database doing? Because current.sql is idempotent, it is not exactly clear how the shadow database is helping.

  2. How would branching work out? I can imagine a lot of merge conflicts on current.sql and even within the migrations folder.

I realize this tool is brand new but FYI, it is not possible to commit a second migration:

Error: Previous migration with hash 'sha1:f2dbea7bf3b31f50e57be68cb3e6fb4c9a6b5924' doesn't match '000002.sql''s expected previous hash 000001.sql

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:19 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
benjiecommented, Apr 18, 2019

a. Where does the pg_dump come in?
b. Is the idea to commit this to git as well?

After ‘graphile-worker commit’ a dump will be made and stored to disk. This should be committed. You can then review the diff to ensure that no breaking changes have take place/you’ve not accidentally dropped things you didn’t mean to.

c. Does it always hang one commit behind the development database?

You can run graphile-migrate dump [--shadow] manually to dump your development (or shadow) database; you can then git diff to ensure you’re changing what you think you’re changing. It’s also useful for cleaning up changes from other branches you may have been working on.

But under normal operation, what would cause the shadow database to drift?

Most likely this will be caused by PG version upgrades.

This is the first time current.sql is being executed against the shadow rather than the development DB correct?

current.sql is ran against the shadow database during commit. I can’t remember if it gets put into committed first or not, that’s an implementation detail really.

Shadow DB receives migrations on commit and Dev DB receives migrations on the start of watch.

Correct; you can also run various commands manually to apply migrations to dev or shadow.

only the commit command reads or writes to the shadow DB.

Whilst this may be true currently, it likely won’t be true going forward. The shadow database is something we can reset on a whim. (The reset --shadow command also resets the shadow db.)

1reaction
benjiecommented, Apr 16, 2019

afterReset (and related hooks) may or may not already do what you need (or be able to do it without much work). In case you’re not familiar with my work, I’m a big fan of hooks and plugins… 😁

Read more comments on GitHub >

github_iconTop Results From Across the Web

Thought Definition & Meaning - Merriam-Webster
noun ; something that is thought: such as ; a · an individual act or product of thinking ; b · a developed...
Read more >
Thought - Wikipedia
In their most common sense, the terms thought and thinking refer to conscious cognitive processes that can happen independently of sensory stimulation.
Read more >
73 Synonyms & Antonyms for THOUGHTS - Thesaurus.com
synonyms for thoughts · attitude · desire · determination · eye · feeling · judgment · mood · opinion ...
Read more >
Meaning of thought in English - Cambridge Dictionary
the act of thinking about something to form ideas and opinions, or an idea or opinion produced by thinking: [ U ] I...
Read more >
Thought | Definition, Types, Examples, & Facts | Britannica
thought, covert symbolic responses to stimuli that are either intrinsic (arising from within) or extrinsic (arising from the environment).
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