efcore.pg icon indicating copy to clipboard operation
efcore.pg copied to clipboard

migration on changed includedPropertyNames for IsGeneratedTsVectorColumn creates up/down code in wrong order

Open springy76 opened this issue 11 months ago • 0 comments

My entity setup has this code:

entityBuilder.Property<NpgsqlTsVector>(AllTextColumnsFullTextComputedColumnName) .IsGeneratedTsVectorColumn(FullTextDictionaryName, FieldsIncludedInFullTextColumn);

where FieldsIncludedInFullTextColumn is a string[].

Now I added a new string property to the entity and added the name as the last entry to FieldsIncludedInFullTextColumn.

Now the migration created by add-migration powershell script does this in Up method:

  1. migrationBuilder.AlterColumn<NpgsqlTsVector>(... // referencing column name of step2
  2. migrationBuilder.AddColumn<string>(...

And so the resulting SQL is also in wrong order:

  1. drop tsvector column
  2. recreate tsvector column referencing column which gets created in step 3
  3. create text column needed for step 2

Same problem with Down method, just in inverse order.

springy76 avatar Mar 21 '24 14:03 springy76