Giter VIP home page Giter VIP logo

postgresqlmigrationsqlgenerator's People

Contributors

darionato avatar dkucinskas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

postgresqlmigrationsqlgenerator's Issues

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.

Error on moving Table to different schema !?

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)
--------------------------------------------------------------

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.