Reputation: 1
I am running a service locally with existing migrations. When applying one of the migrations, I get an error 'column cannot be cast automatically to type bigint.' What could be the issue if the service is currently working in production? Migration was created with ef core 6 I use ef core 8
Migration:
migrationBuilder.AlterColumn<long>(
name: "external_id",
table: "pickup_points",
type: "bigint",
nullable: false,
oldClrType: typeof(string),
oldType: "text");
If I change type to "bigint USING external_id::bigint" it works. Why does this happen?
Upvotes: 0
Views: 455
Reputation: 16722
This is expected - PostgreSQL refuses to just change column types when the conversion isn't guaranteed to be successful; for example, your old text
column could contain non-numeric data. Note that if you converted the other way around (bigint
-> text
), you would not get this error.
Upvotes: 0