edgedb / edgedb

A graph-relational database with declarative schema, built-in migration system, and a next-generation query language
https://edgedb.com
Apache License 2.0
12.93k stars 396 forks source link

Migrations can't change a pointer's type while rebasing it #3119

Open msullivan opened 2 years ago

msullivan commented 2 years ago

In the test test_edgeql_migration_reject_prop_05, we try to do the migration

scalar type Slug extending str;
abstract type Named {
    required property name -> Slug;
};
type User {
    required property name -> str;
};

to

scalar type Slug extending str;
abstract type Named {
    required property name -> Slug;
};
type User extending Named;

The initial migration proposed is the somewhat dubious "drop name, recreate it", which has the virtue of at least successfully applying.

If we reject that, though, and ask to keep the existing name, we generate a migration that tries to rebase User onto Named and then set the type of name. This doesn't work, since the rebase fails due to the type conflict.

To make this work, we need to generate a SET TYPE that goes before the rebase to make the types match up before the rebase can happen. I think this might require drawing some more distinctions in ordering, since I think normally we try to put changes after a rebase.

haikyuu commented 1 year ago

I think I ran into the same issue (using 3.1)

InternalServerError: dependency cycle between 

('rebase', 'default::__|root@default|Theme') and ('rebase', 'default::Theme')

I still don't have Data to lose, so I started from scratch and it worked

haikyuu commented 1 year ago

And again :)

Schema migration error: InternalServerError: dependency cycle between ('dropowned', 'default::__|_revisions@default|Theme') 

and ('rebase', 'default::Theme')