Closed jtmorrisbytes closed 1 year ago
Hey @jtmorrisbytes, I moved this issue to SeaQuery repository as it's more related to the query builder.
I did some digging and indeed serial
is only applicable on table creation but not modification. https://dbfiddle.uk/TEnDJWeb
I just drafted a PR for this, feel free to check it :)
Description
When writing a migration using sea-orm-migration, manager.alter_table() produces SQL with 'bigserial' and 'serial' as a data type on the postgres backend when the column is a primary key with auto-increment set to true. this happens even when attribute 'column_type' is applied to the struct definition.
Steps to Reproduce
execute a alter table statement with primary_key=true, auto_increment=true, and either i32 or i64 as rust types and 'Integer or BigInteger' as column_types respectively on a postgres backend using schema introspection
Expected Behavior
adding or modifying a column in a postgres backend should use 'integer' and 'biginteger' respectively and require the programmer to manually create the sequences
Actual Behavior
sea orm outputs 'serial' and 'bigserial' causing the migration to fail The terminal used to run migrations displays 'Execution Error: error returned from database: type "bigserial" does not exist'
Reproduces How Often
Always (every time)
Workarounds
I prepose not to use 'bigserial' and 'serial' as data types in the context of altering a table and instead leave creating or altering sequences to the programmer
Reproducible Example
Versions
sea-orm 0.11.3 sea-orm-migration 0.11.3 postgres version 15 windows 11 22H2