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

Regression: SQLite fails to create create AUTO_INCREMENT big_integer #1973

Closed
secana opened this issue Nov 19, 2023 · 7 comments
Closed

Regression: SQLite fails to create create AUTO_INCREMENT big_integer #1973

secana opened this issue Nov 19, 2023 · 7 comments

Comments

@secana
Copy link

secana commented Nov 19, 2023

Description

Upgrade from sea-orm-migration = 0.11.3 to sea-orm-migrations = 0.12.6 breaks SQLite table creation with AUTOINCREMENT is only allowed on an INTEGER PRIMARY KEY

Steps to Reproduce

  1. Create a simple SQLite table with big_integer as the index.
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
        manager
            .create_table(
                Table::create()
                    .table(UserIden::Table)
                    .if_not_exists()
                    .col(
                        ColumnDef::new(UserIden::Id)
                            .big_integer() // <--- Works fine in sea-orm 0.11.3
                            .not_null()
                            .auto_increment()
                            .primary_key(),
                    )
                    .col(
                        ColumnDef::new(UserIden::Name)
                            .text()
                            .unique_key()
                            .not_null(),
                    )
                    .col(ColumnDef::new(UserIden::Pwd).text().not_null())
                    .col(ColumnDef::new(UserIden::Salt).text().not_null())
                    .col(ColumnDef::new(UserIden::IsAdmin).boolean().not_null())
                    .to_owned(),
            )
            .await
}

Everything works fine and the table is created correctly.

  1. Upgrade sea-orm

Upgrade sea-orm / sea-orm-migrations to 0.12.6 and run the code above again. Now, the table creation breaks with AUTOINCREMENT is only allowed on an INTEGER PRIMARY KEY.

Expected Behavior

SQLite table is created with a big_integer index.

Actual Behavior

Table creation fails with AUTOINCREMENT is only allowed on an INTEGER PRIMARY KEY.

Reproduces How Often

Always

Workarounds

Instead of big_integer, integer can be used and the code works again. Unfortunatly that is not an option as the all database table are already created with big_integer, such that a migration to integer would break all of the production databases.

Versions

Upgrade from 0.11.3 to 0.12.6

@secana
Copy link
Author

secana commented Nov 19, 2023

Remark: The code works fine for PostgreSQL, it only affects SQLite.

@tyt2y3
Copy link
Member

tyt2y3 commented Nov 21, 2023

Thank you for your report. Yes I am aware, and is tracked in SeaQL/sea-query#689
The workaround is to change it to integer() for primary keys. I probably would fix it soon.

@secana
Copy link
Author

secana commented Nov 21, 2023

Thanks for the feedback. I looked here for an existing issue and didn't find one. Haven't though of looking in the sea-query repo. As the issue is already tracked, I'll close this one as a duplicate.

@secana secana closed this as completed Nov 21, 2023
@tyt2y3
Copy link
Member

tyt2y3 commented Nov 21, 2023

No worries!

@vrozhdestvenskyi
Copy link

Hey guys, any updates on this?
At 0.12.15, the table is created correctly but the generated struct Model has the primary key field of type i32 but not i64

@tyt2y3
Copy link
Member

tyt2y3 commented May 14, 2024

You can try 1.0-rc

@vrozhdestvenskyi
Copy link

Thanks for the quick reply! Unfortunately, it's the same for the latest 1.0.0-rc.4 version.

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

3 participants