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

sqlite-utils transform removes the AUTOINCREMENT keyword #602

Open
ArsTapatun opened this issue Nov 6, 2023 · 0 comments
Open

sqlite-utils transform removes the AUTOINCREMENT keyword #602

ArsTapatun opened this issue Nov 6, 2023 · 0 comments

Comments

@ArsTapatun
Copy link

Context

We ran into this bug randomly, noticing that deleted ROWID would get reused after migrating the DB. Using transform to change any column in the table will also unexpectedly strip away the AUTOINCREMENT keyword from the primary key definition, even if it was not the transformation target.

Reproducible example

Original database

$ sqlite3 test.db << EOF
CREATE TABLE mytable (
    col1 INTEGER PRIMARY KEY AUTOINCREMENT,
    col2 TEXT NOT NULL
)
EOF

$ sqlite3 test.db ".schema mytable"
CREATE TABLE mytable (
    col1 INTEGER PRIMARY KEY AUTOINCREMENT,
    col2 TEXT NOT NULL
);

Modified database after sqlite-utils

$ sqlite-utils transform test.db mytable --rename col2 renamedcol2

$ sqlite3 test.db "SELECT sql FROM sqlite_master WHERE name = 'mytable';"
CREATE TABLE IF NOT EXISTS "mytable" (
   [col1] INTEGER PRIMARY KEY,
   [renamedcol2] TEXT NOT NULL
);
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

1 participant