Skip to content

Collation lost when changing type from varchar to text #3476

@Verdurakh

Description

@Verdurakh

Bug description

When changing a type of a column from varchar to text the previously set collation seems to be lost.

The migration adds a Alter Column statement specifying the same collation for both old and new.

My expected sql code would have been something like

ALTER TABLE address ALTER COLUMN tag TYPE text COLLATE case_insensitive;
which if done manually works and keeps the collation but this is not what is happening in the migration.

orginial Entity Configuration
	builder.Property(address => address.Tag).HasMaxLength(50);            
When removing the HasMaxLength(5) the below migration is created.

public class AddressEntity 
{
	
	public required string? Tag { get; set; }
}



migrationBuilder.AlterColumn<string>(
                name: "tag",
                table: "address",
                type: "text",
                nullable: true,
                collation: "case_insensitive",
                oldClrType: typeof(string),
                oldType: "character varying(50)",
                oldMaxLength: 50,
                oldNullable: true,
                oldCollation: "case_insensitive");

After this the collation for this column is null

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions