-
Notifications
You must be signed in to change notification settings - Fork 127
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
Postgresql - few issues #189
Comments
First issue: are you using migrationGenerator directly or via CompareSchemas? //CREATE TABLE employees (
// employee_id SERIAL PRIMARY KEY,
// name VARCHAR(100),
// manager_id INTEGER,
// FOREIGN KEY (manager_id) REFERENCES employees(employee_id)
//);
var schema = new DatabaseSchema(null, SqlType.PostgreSql);
schema.AddTable("employees")
.AddColumn<int>("employee_id").AddIdentity().AddPrimaryKey("pkEmployees")
.AddColumn<string>("name").AddLength(100)
.AddColumn<int>("manager_id")
.AddForeignKey("manager_id", "employees", "employee_id");
var schema2 = new DatabaseSchema(null, SqlType.PostgreSql);
schema2.AddTable("employees")
.AddColumn<int>("employee_id")
.AddColumn<string>("name").AddLength(100)
.AddColumn<int>("manager_id");
var comparer = new CompareSchemas(schema,schema2);
var migration = comparer.Execute();
Console.WriteLine(migration); |
Second issue: if you're using the .AddColumn("x") it's mapped using a class called PostgreSqlDataTypeMapper to the pgsql type decimal. This is of course just an alias of NUMERIC, and with different precisions you could map to different types. In that case you have to define it manually (set the column DataType and DbDataType)- or create an extension that does it for you (eg AddPgSqlNumeric). If you're using compare between two actual schemas read from databases, the DataTypes should be correct |
Third issue is tough, and occurs in other databases too. You have to set the next value of the serial sequence/identity to the max(id)+1 of the column. The last time I did that we used a bigger round number, for business reasons so we could tell the old defaults from the new identity- writing the code automatically may be dangerous here. |
Hi, we have encountered some issues when testing schemareader and generating migrations on PostgreSQL
The text was updated successfully, but these errors were encountered: