sqldelight
sqldelight copied to clipboard
Intellij plugin doesn't recognize that indexes of a dropped table are dropped
SQLDelight Version
2.0.0
IDE Version
Android Studio Giraffe | 2022.3.1 Patch 1
Dialect
SQLite
Describe the Bug
Given a table with two fields and two indexes for each field.
- Create a database migration for renaming one of the fields.
- Auto-generated migration will:
- create a temp-table
- copy data from original table into that table
- drops original table
- alter temp-table name into original one.
- Because indexes for a dropped table are also dropped, they need to be re-added manually.
- Add missing indexes for the table
- Intellij plugin shows "Duplicate index name" error.
- If indexes are not added manually, verifySqlDelightMigration tasks shows that they were dropped and they are missing in the database after migration.
Expected behavior:
- When a table is dropped, Intellij plugin must consider indexes to be dropped as well.
- Auto-generated migration must re-create all dropped indexes.
Temporal workaround: before dropping a table, drop all indexes of that table in migration script. This allows index re-creation.
Stacktrace
No response
Any fixes planned?
Additional sample
1.sqm
-- Create table with index
CREATE TABLE Table1(
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
paretnId INTEGER NOT NULL
);
CREATE INDEX Table1_paretnId ON Table1 (paretnId);
2.sqm
-- Drop table (automatically drop index)
DROP TABLE Table1;
-- Create table with index
CREATE TABLE Table1(
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
paretnId INTEGER NOT NULL,
name TEXT
);
CREATE INDEX Table1_paretnId ON Table1 (paretnId); -- Warning "Duplicate index name Table1_paretnId"