Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on changing parameter type. #4

Open
borisdj opened this issue Apr 26, 2013 · 0 comments
Open

Error on changing parameter type. #4

borisdj opened this issue Apr 26, 2013 · 0 comments

Comments

@borisdj
Copy link

borisdj commented Apr 26, 2013

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant