PostgreSqlMigrationSqlGenerator
PostgreSqlMigrationSqlGenerator copied to clipboard
Error on changing parameter type.
I have found anotother bug, you can't change type of parameter. For example if have -------------------------------------------------------------- public string Code { get; set; } -------------------------------------------------------------- and change it to -------------------------------------------------------------- public int Code { get; set; } -------------------------------------------------------------- script build is successfully but update-database fails.
I have found what is causing this and how to fix it. In PostgreSql Alter Column query requires USING (col_name::type); in this case USING ("Code"::integer);
The fix is following (just 2 lines of code): -------------------------------------------------------------- if (isAlter) writer.Write(" USING ({0}::{1})", Quote(column.Name), BuildColumnType(column)); -------------------------------------------------------------- Add this into PostgreSqlMigrationSqlGenerator in function private void Generate(ColumnModel column, IndentedTextWriter writer, bool isAlter = false) just after next code: -------------------------------------------------------------- // check if it has a max length if (column.MaxLength != null && column.MaxLength > 0) writer.Write("({0})", column.MaxLength); -------------------------------------------------------------- I have tested it and it works. You can check it and update your project when you get time, after that mark this issue as fixed.