darionato / postgresqlmigrationsqlgenerator Goto Github PK
View Code? Open in Web Editor NEWClass to handle Entity Framework migrations with PostgreSQL
License: Other
Class to handle Entity Framework migrations with PostgreSQL
License: Other
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.
I'd like to reuse this code, but can't without a license. Ideally you could license under something like BSD/Apache, as code on GitHub is copyright all rights reserved by default.
e.g. Drop in http://www.apache.org/licenses/LICENSE-2.0
The type or namespace name 'NegoziazioneEventi' could not be found (are you missing a using directive or an assembly reference?)
Table by default will be put into 'dbo' schema.
If I want to specify another schema I can do it like this:
--------------------------------------------------------------
[Table("Movie", Schema = "cinema")]
--------------------------------------------------------------
and it works fine.
But once I make table, and then I want to change it's schema it does not works.
It successfully makes migration script:
--------------------------------------------------------------
MoveTable(name: "dbo.Movie", newSchema: "cinema");
--------------------------------------------------------------
but on executing it gives error:
--------------------------------------------------------------
Npgsql.NpgsqlException:
syntax error at or near "TRANSFER"
Severity: ERROR
Code: 42601
at Npgsql.NpgsqlState.<ProcessBackendResponses_Ver_3>d__a.MoveNext()
at Npgsql.ForwardsOnlyDataReader.GetNextResponseObject()
at Npgsql.ForwardsOnlyDataReader.GetNextRowDescription()
at Npgsql.ForwardsOnlyDataReader.NextResult()
at Npgsql.ForwardsOnlyDataReader..ctor(IEnumerable`1 dataEnumeration, CommandBehavior behavior, NpgsqlCommand command, NotificationThreadBlock threadBlock, Boolean synchOnReadError)
at Npgsql.NpgsqlCommand.GetReader(CommandBehavior cb)
at Npgsql.NpgsqlCommand.ExecuteNonQuery()
at System.Data.Entity.Migrations.DbMigrator.ExecuteSql(DbTransaction transaction, MigrationStatement migrationStatement)
--------------------------------------------------------------
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.