Skip to content

Commit d21a497

Browse files
feat(db): drop the opened_at column instead of marking deprecated
1 parent a15235c commit d21a497

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

invokeai/app/services/shared/sqlite_migrator/migrations/migration_18.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ def __call__(self, cursor: sqlite3.Cursor) -> None:
1010
def _make_workflow_opened_at_nullable(self, cursor: sqlite3.Cursor) -> None:
1111
"""
1212
Make the `opened_at` column nullable in the `workflow_library` table. This is accomplished by:
13-
- Renaming the existing column to `opened_at_deprecated`
14-
- Drop the existing `idx_workflow_library_opened_at` index
13+
- Dropping the existing `idx_workflow_library_opened_at` index (must be done before dropping the column)
14+
- Dropping the existing `opened_at` column
1515
- Adding a new nullable column `opened_at` (no data migration needed, all values will be NULL)
16-
- Recreate the `idx_workflow_library_opened_at` index on the `opened_at` column
16+
- Adding a new `idx_workflow_library_opened_at` index on the `opened_at` column
1717
"""
18-
# Rename existing column to deprecated
19-
cursor.execute("ALTER TABLE workflow_library RENAME COLUMN opened_at TO opened_at_deprecated;")
2018
# For index renaming in SQLite, we need to drop and recreate
2119
cursor.execute("DROP INDEX IF EXISTS idx_workflow_library_opened_at;")
20+
# Rename existing column to deprecated
21+
cursor.execute("ALTER TABLE workflow_library DROP COLUMN opened_at;")
2222
# Add new nullable column - all values will be NULL - no migration of data needed
2323
cursor.execute("ALTER TABLE workflow_library ADD COLUMN opened_at DATETIME;")
2424
# Create new index on the new column
@@ -33,10 +33,10 @@ def build_migration_18() -> Migration:
3333
3434
This migration does the following:
3535
- Make the `opened_at` column nullable in the `workflow_library` table. This is accomplished by:
36-
- Renaming the existing column to `opened_at_deprecated`
37-
- Drop the existing `idx_workflow_library_opened_at` index
36+
- Dropping the existing `idx_workflow_library_opened_at` index (must be done before dropping the column)
37+
- Dropping the existing `opened_at` column
3838
- Adding a new nullable column `opened_at` (no data migration needed, all values will be NULL)
39-
- Recreate the `idx_workflow_library_opened_at` index on the `opened_at` column
39+
- Adding a new `idx_workflow_library_opened_at` index on the `opened_at` column
4040
"""
4141
migration_18 = Migration(
4242
from_version=17,

0 commit comments

Comments
 (0)