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
);
Context
We ran into this bug randomly, noticing that deleted
ROWID
would get reused after migrating the DB. Usingtransform
to change any column in the table will also unexpectedly strip away theAUTOINCREMENT
keyword from the primary key definition, even if it was not the transformation target.Reproducible example
Original database
Modified database after sqlite-utils