edgedb-cli
edgedb-cli copied to clipboard
Migration edit bug in nightly build
- EdgeDB Version: nightly (EdgeDB 3.0-dev.6990+71197ab (repl 2.1.0-dev.857+fb44665))
- EdgeDB CLI Version: nightly (EdgeDB CLI 2.1.0-dev.857+fb44665)
- OS Version: Ubuntu 22
Steps to Reproduce:
First start a new project:
victor@work ~/dev/foo $ edgedb project init
No `edgedb.toml` found in `/home/victor/dev/foo` or above
Do you want to initialize a new project? [Y/n]
> Y
Specify the name of EdgeDB instance to use with this project [default: foo]:
> foo
Checking EdgeDB versions...
Specify the version of EdgeDB to use with this project [default: 2.4]:
> nightly
┌─────────────────────┬──────────────────────────────────┐
│ Project directory │ /home/victor/dev/foo │
│ Project config │ /home/victor/dev/foo/edgedb.toml │
│ Schema dir (empty) │ /home/victor/dev/foo/dbschema │
│ Installation method │ portable package │
│ Version │ 3.0-dev.6990+71197ab │
│ Instance name │ foo │
└─────────────────────┴──────────────────────────────────┘
Downloading package...
00:00:00 [====================] 35.73 MiB/35.73 MiB 84.78 MiB/s | ETA: 0s Successfully installed 3.0-dev.6990+71197ab
Initializing EdgeDB instance...
[systemctl] Created symlink /home/victor/.config/systemd/user/default.target.wants/[email protected] → /home/victor/.config/systemd/user/[email protected].
[systemctl] Created symlink /home/victor/.config/systemd/user/default.target.wants/[email protected] → /home/victor/.config/systemd/user/[email protected].
Applying migrations...
Everything is up to date. Revision initial
Project initialized.
To connect to foo, run `edgedb`
So far, so good. Now edit the default.esdl
to this:
module default {
type Foo {
required property name -> str;
}
}
And create a migration:
victor@work ~/dev/foo $ edgedb migration create
Created dbschema/migrations/00001.edgeql, id: m1gwnkg6mkie3on2baunai3qic62x2c2ai22rmtrjvpwnqmjffgtka
victor@work ~/dev/foo $ edgedb migration apply
Applied m1gwnkg6mkie3on2baunai3qic62x2c2ai22rmtrjvpwnqmjffgtka (00001.edgeql)
Now, edit the schema to rename the name
to val
and create a new migration:
victor@work ~/dev/foo $ edgedb migration create
did you rename property 'name' of object type 'default::Foo' to 'val'? [y,n,l,c,b,s,q,?]
> y
Created dbschema/migrations/00002.edgeql, id: m16ew5nr7g4vaq6rrttopxmfxdumendidmcvqzhgqmx2hkhhpl63wa
Before applying the migration edit it to add insert Foo {val := 'test'};
:
victor@work ~/dev/foo $ edgedb migration edit
Updated migration id to m13wj4672mwihw7ffvogb7wgl7aftjtn3bnl7jchr3d36nrjcwdvsq
error: SchemaDefinitionError: specified migration name does not match the name derived from the migration contents: 'm16ew5nr7g4vaq6rrttopxmfxdumendidmcvqzhgqmx2hkhhpl63wa', expected 'm13wj4672mwihw7ffvogb7wgl7aftjtn3bnl7jchr3d36nrjcwdvsq'
┌─ query:1:18
│
1 │ CREATE MIGRATION m16ew5nr7g4vaq6rrttopxmfxdumendidmcvqzhgqmx2hkhhpl63wa
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error
edgedb error: error checking migration: SchemaDefinitionError: specified migration name does not match the name derived from the migration contents: 'm16ew5nr7g4vaq6rrttopxmfxdumendidmcvqzhgqmx2hkhhpl63wa', expected 'm13wj4672mwihw7ffvogb7wgl7aftjtn3bnl7jchr3d36nrjcwdvsq'
Edit again? [y,f,d,r,q,?]
...that's weird, I expect the migration hash to not match because I've just edited it and the command should know that. So I "try again" without making any more changes, just reusing the edited file:
> y
Id m13wj4672mwihw7ffvogb7wgl7aftjtn3bnl7jchr3d36nrjcwdvsq is already correct.
edgedb error: error checking migration: TransactionError: current transaction is aborted, commands ignored until end of transaction block
Edit again? [y,f,d,r,q,?]
> y
Id m13wj4672mwihw7ffvogb7wgl7aftjtn3bnl7jchr3d36nrjcwdvsq is already correct.
edgedb error: error checking migration: ClientInconsistentError: Connection is inconsistent state. Please reconnect.
Edit again? [y,f,d,r,q,?]
> y
Id m13wj4672mwihw7ffvogb7wgl7aftjtn3bnl7jchr3d36nrjcwdvsq is already correct.
edgedb error: error checking migration: ClientInconsistentError: Connection is inconsistent state. Please reconnect.
Edit again? [y,f,d,r,q,?]
> q
The error message changed, no longer complaining about the migration hash, but instead having an issue with transaction and eventually connection state. This is all for the same exact edited migration file:
CREATE MIGRATION m13wj4672mwihw7ffvogb7wgl7aftjtn3bnl7jchr3d36nrjcwdvsq
ONTO m1gwnkg6mkie3on2baunai3qic62x2c2ai22rmtrjvpwnqmjffgtka
{
ALTER TYPE default::Foo {
ALTER PROPERTY name {
RENAME TO val;
};
};
insert Foo {val := 'test'};
};
BTW, the error message has a typo, it should be Connection is in an inconsistent state.
.
So I just connect to the instance and check if there's a problem:
victor@work ~/dev/foo $ edgedb
EdgeDB 3.0-dev.6990+71197ab (repl 2.1.0-dev.857+fb44665)
Type \help for help, \quit to quit.
edgedb> \ds
module default {
type Foo {
required property name -> std::str;
};
};
edgedb>
No problem, but now I can "edit" the migration:
victor@work ~/dev/foo $ edgedb migration edit
Previously edited file exists. Restore? [y,n,d,?]
> y
Id m13wj4672mwihw7ffvogb7wgl7aftjtn3bnl7jchr3d36nrjcwdvsq is already correct.
victor@work ~/dev/foo $ edgedb migrate
Applied m13wj4672mwihw7ffvogb7wgl7aftjtn3bnl7jchr3d36nrjcwdvsq (00002.edgeql)
I cannot edit a committed migration and that seems to work as expected:
victor@work ~/dev/foo $ edgedb migration edit
Updated migration id to m1jjrgmwzdynzpijyotzmh75v72icuhxseujlv54ep4xxywtop7qta
error: SchemaDefinitionError: specified migration parent is not the most recent migration, expected 'm13wj4672mwihw7ffvogb7wgl7aftjtn3bnl7jchr3d36nrjcwdvsq'
┌─ query:2:10
│
2 │ ONTO m1gwnkg6mkie3on2baunai3qic62x2c2ai22rmtrjvpwnqmjffgtka
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error
edgedb error: error checking migration: SchemaDefinitionError: specified migration parent is not the most recent migration, expected 'm13wj4672mwihw7ffvogb7wgl7aftjtn3bnl7jchr3d36nrjcwdvsq'
Edit again? [y,f,d,r,q,?]
> q
edgedb error: Aborted!