-
Notifications
You must be signed in to change notification settings - Fork 433
Description
GEL Migration Bug: Cannot Add Abstract Type Parent to Existing Types
Date: 2025-01-20
GEL Version: 6.11+66a1377
Severity: High - Blocks adding new abstract types to existing schemas
Summary
GEL migration generator fails with InvalidConstraintDefinitionError: constraints on object types must have an 'on' clause when attempting to add a new abstract type as a parent to existing concrete types, even when the abstract type contains no type-level constraints.
Reproduction Steps
Step 1: Start with existing schema
Create initial migration with abstract types and concrete types:
# base.gel
abstract type Versioned { ... }
abstract type SoftDeletable { ... }
# concept.gel
type Concept extending Versioned, SoftDeletable { ... }Apply migration → Works fine.
Step 2: Add new abstract type to schema
# base.gel - ADD NEW ABSTRACT TYPE
abstract type Proposable {
required property status -> ProposalStatus {
default := ProposalStatus.confirmed;
}
}Create migration, apply → Works fine (abstract type created).
Step 3: Extend existing type with new abstract type
# concept.gel - EXTEND WITH NEW ABSTRACT TYPE
type Concept extending Versioned, SoftDeletable, Proposable { ... }Run gel migration create --non-interactive
Result: ❌ Migration fails with error:
gel error: InvalidConstraintDefinitionError: constraints on object types must have an 'on' clause
Expected Behavior
Migration should succeed with DDL similar to:
ALTER TYPE default::Concept EXTENDING Proposable;Actual Behavior
Migration generation fails immediately with constraint error, even though:
- Proposable has no type-level
constraint expression on (...) - The error message is misleading (no constraints need fixing)
- The same schema works fine if created in initial migration
Workaround
Delete all migrations and recreate from scratch with the new abstract type included in the initial migration. This works because GEL can handle CREATE TYPE ... EXTENDING AbstractType but cannot handle ALTER TYPE ... EXTENDING AbstractType.
Workaround steps:
- Destroy database instances
- Delete all migration files
- Run
gel migration createto generate initial migration with both old and new abstract types - Run
gel migrateto apply
Minimal Test Case
File: base.gel
module default {
abstract type Proposable {
required property test -> bool {
default := false;
}
}
}File: concept.gel
module default {
type Concept {
required property name -> str;
}
}Steps:
- Create initial migration → Apply
- Edit concept.gel:
type Concept extending Proposable { ... } - Run
gel migration create --non-interactive - Error occurs
Additional Context
- Works fine when abstract type and extensions are in same migration (initial migration)
- Fails when trying to add abstract type parent to existing concrete type in later migration
- Error message is misleading - suggests constraint syntax issue but no constraints are malformed
- Same pattern works fine for other schema operations (adding properties, links, etc.)
- Other abstract types (Versioned, SoftDeletable, Auditable) work because they were in initial migration
Environment
- OS: Windows (WSL)
- GEL Version: 6.11+66a1377
- Installation Method: WSL
- Command:
gel migration create --non-interactive