You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have to have a command to run the check once (this is a primary command to run before upgrading, --watch is only needed once you did the check and figured out that something is wrong and are actively editing the schema)
It has to have all kinds of version aguments --to-testing, --to-nightly, --to-channel, which don't make sense for watch
What it does:
Spawns a teporary instance
Applies the latest schema and checks whether it's okay
Applies all the migrations and checks if it's okay
So it has one of the two outcomes:
You're all set, feel free to upgrade
You're schema is compatible, but migrations are not. Please do the squash of the schema before upgrading.
(the messages are rough, we should provide actual instructions for the latter)
Not-watch mode can also indicate a schema error:
The schema is not compatible to the EdgeDB 3.0. Please fix the errors above.
hint: Use `edgedb migration upgrade-check --watch` for faster feedback loop.
If upgrade check is clean without squashing, user may proceed the upgrade without further work. So the following text only discusses failure scenario
Here are three possible ways to implement failure workflow:
No-Bookkeeping Workflow
edgedb migration create --squash
Requires no schema changes comparing to current migrations
Replaces all revisions to 0001.edgeql that records previous one as
annotation:
CREATE MIGRATION ... {
SET squashed_from := "m1askdfjasdihslkjvdahfowerafahd";
}
In this case, edgedb migrate will apply to the database following these
guidelines:
Only first migration can contain squashed_from
If the first (squashed) revision in the database, migration proceeds normally
If squashed_from revision is the latest, it's replaced with the new first revision
If squashed_from revision is not in the database or not the latest one, it's the fatal error
From user point of view full process looks like this:
Run migration update-check --watch and fix the schema
Run (normal) migration create
Push all the revisions to all shared databases
Run migration create --squash
Do dev database upgrade and check your app
Push that to all shared databases
Do shared database upgrade
Fixup Workflow
edgedb migration create --squash
Does two things:
Replaces all revisions into 0001.edgeql
And creates a fixup file that contains a difference from the latest migration in the filesystem to schema:
Fixup file is created via normal (interactive) migration construction process.
In this case, edgedb migrate when encounters a revision that is not in the database and can't be upgraded to:
Looks for a fixup file <db_revision>-<file_revision>.edgeql
If that fixup exists applies migration and does rebase
If fixup for 00001.edgeq does not exist, repeat process for the next revisions
From user point of view full process looks like this:
Run migration update-check --watch and fix the schema
Run migration create --squash
Do dev database upgrade and check your app
Eventually push your change do the shared databases
Do update of shared databases once migrations are applied
Advantages of this workflow:
Squashing can be done right away (with the no bookkeeping workflow you have to deploy migrations to all the shared databases before you can do squash)
Fixups from multiple revisions can coexist
Fixup files could be kept indefinitely, to restore from backups (although, this only works for backups having exactly the same latest revision)
Can fixup arbitrary revision, i.e. shared database that was deployed from a branch, or to recover from DDL (comparing to Diamond Workflow)
Fixups can contain data migrations specific to this upgrade
Diamond Workflow
This allows keeping multiple revision hierarchies.
edgedb migration create --squash
Requires no schema changes comparing to current migrations
Creates a combined revision:
dbschema/migrations/00001-00265.edgeql
In this case, edgedb migrate:
Applies all revisions up to 265
Rebases to use 00001-00265.edgeql instead
Proceeds next revisions normally
New instances skip fine-grained revisions
From user point of view full process looks like this:
Run migration update-check --watch and fix the schema
Run migration create --squash
Do dev database upgrade and check your app
Eventually push your change do the shared databases
Do update of shared databases once migrations are applied
Advantages of this workflow:
Squashing can be done right away (with the no bookkeeping workflow you have to deploy migrations to all the shared databases before you can do squash)
Old revision files could be kept indefinitely, to restore from backups
Revisions from git branches keep their numbers (although have to be rebased anyways)
Cons:
Fine-grained revision that are left could contain code that is invalid in the new edgedb. And that is confusingly stored in the git (even though, we can allow deleting those files, users will unlikely be doing that).
Conclusion
My choice is "Fixup Workflow" for now. As it's the most versatile, and is also easier to implement that Diamond workflow, and also equivalent in convenience.
The following scenario is fine under Fixup workflow and particularly bad under both of the alternatives:
Schema is updated and squashed
Some dev instances are upgraded (staging, local)
Bug is found in the application that requires changing schema again
No bookkeping: best way to proceed is revert git and redo process again, dropping/restoring from backup all the databases that has already adopded squashed schema
Fixup: squash the schema again and provide fixup both from both parents.
Note: No-Bookkeeping Workflow may look like a subset of the Fixup Workflow. But that depends on how bookkeeping of "empty fixups" is done. In No-bookeeping workflow that is recorded in the squash migration. I think that storing that in fixup file is more robust, as modifying an annotation of squashed revision changes its hash.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This discusses approaches for: geldata/gel-cli#976
Local glossary:
(yes
stagingis in some sense a shared database, and in some sense dev database)Upgrade Check
Not
edgedb watchbecause:--watchis only needed once you did the check and figured out that something is wrong and are actively editing the schema)--to-testing, --to-nightly, --to-channel, which don't make sense for watchWhat it does:
So it has one of the two outcomes:
(the messages are rough, we should provide actual instructions for the latter)
Not-watch mode can also indicate a schema error:
If upgrade check is clean without squashing, user may proceed the upgrade without further work. So the following text only discusses failure scenario
Here are three possible ways to implement failure workflow:
No-Bookkeeping Workflow
0001.edgeqlthat records previous one asannotation:
In this case,
edgedb migratewill apply to the database following theseguidelines:
squashed_fromsquashed_fromrevision is the latest, it's replaced with the new first revisionsquashed_fromrevision is not in the database or not the latest one, it's the fatal errorFrom user point of view full process looks like this:
migration update-check --watchand fix the schemamigration createmigration create --squashFixup Workflow
Does two things:
0001.edgeqlIn this case,
edgedb migratewhen encounters a revision that is not in the database and can't be upgraded to:<db_revision>-<file_revision>.edgeqlFrom user point of view full process looks like this:
migration update-check --watchand fix the schemamigration create --squashAdvantages of this workflow:
Diamond Workflow
This allows keeping multiple revision hierarchies.
In this case,
edgedb migrate:00001-00265.edgeqlinsteadFrom user point of view full process looks like this:
migration update-check --watchand fix the schemamigration create --squashAdvantages of this workflow:
Cons:
Conclusion
My choice is "Fixup Workflow" for now. As it's the most versatile, and is also easier to implement that Diamond workflow, and also equivalent in convenience.
The following scenario is fine under Fixup workflow and particularly bad under both of the alternatives:
Note: No-Bookkeeping Workflow may look like a subset of the Fixup Workflow. But that depends on how bookkeeping of "empty fixups" is done. In No-bookeeping workflow that is recorded in the squash migration. I think that storing that in fixup file is more robust, as modifying an annotation of squashed revision changes its hash.
Beta Was this translation helpful? Give feedback.
All reactions