-
Notifications
You must be signed in to change notification settings - Fork 254
Description
Our current support of PostgreSQL-specific database objects (extensions, enums, ranges, soon hopefully composites) is currently done purely via annotations - objects are represented as metadata on the model, which are then flowed into migrations via annotations on AlterDatabaseOperation. This is unlike EF Core's support for sequences, for example, which has metadata annotations (like us) but then picks up the sequences in the ModelDiffer, which then generates special {Create,Drop,Rename}SequenceOperation.
Our approach is problematic for the following reasons:
- Addition/removal of objects needs to be done in our MigrationsSqlGenerator - compare old and new annotations on an AlterDatabaseOperation, calculate what was added, what was removed, etc. This work conceptually belongs in ModelDiffer rather than in MigrationsSqlGenerator.
- It's impossible to implement correct DefaultSchema support, because we have no way of knowing that the DefaultSchema has changed, and that our database objects need to be moved accordingly (see Schema enums follow up (part 2) #685 (comment)).
In the past, we already have a discussion about providing our own ModelDiffer, which would generate custom migration operations (e.g. CreateEnumOperation). This would be a better design and align us with the way EF Core does things. It may be worth revisiting for 3.0 in case we change our minds.