@@ -21,6 +21,7 @@ def upgrade() -> None:
21
21
# To add ON DELETE CASCADE to the foreign key constraint, we need to
22
22
# rename the table, create a new table with the constraint, and copy
23
23
# the data over.
24
+ op .execute ("DROP TABLE IF EXISTS _prompts_old;" )
24
25
op .execute ("ALTER TABLE prompts RENAME TO _prompts_old;" )
25
26
op .execute (
26
27
"""
@@ -39,6 +40,7 @@ def upgrade() -> None:
39
40
op .execute ("DROP TABLE _prompts_old;" )
40
41
41
42
# Doing the same for the sessions table
43
+ op .execute ("DROP TABLE IF EXISTS _sessions_old;" )
42
44
op .execute ("ALTER TABLE sessions RENAME TO _sessions_old;" )
43
45
op .execute (
44
46
"""
@@ -54,6 +56,7 @@ def upgrade() -> None:
54
56
op .execute ("DROP TABLE _sessions_old;" )
55
57
56
58
# Doing the same for the output table
59
+ op .execute ("DROP TABLE IF EXISTS _outputs_old;" )
57
60
op .execute ("ALTER TABLE outputs RENAME TO _outputs_old;" )
58
61
op .execute (
59
62
"""
@@ -70,6 +73,7 @@ def upgrade() -> None:
70
73
op .execute ("DROP TABLE _outputs_old;" )
71
74
72
75
# Doing the same for the alerts table
76
+ op .execute ("DROP TABLE IF EXISTS _alerts_old;" )
73
77
op .execute ("ALTER TABLE alerts RENAME TO _alerts_old;" )
74
78
op .execute (
75
79
"""
@@ -89,7 +93,7 @@ def upgrade() -> None:
89
93
op .execute ("DROP TABLE _alerts_old;" )
90
94
91
95
# Dropping unused table
92
- op .execute ("DROP TABLE settings;" )
96
+ op .execute ("DROP TABLE IF EXISTS settings;" )
93
97
94
98
# Create indexes for foreign keys
95
99
op .execute ("CREATE INDEX idx_outputs_prompt_id ON outputs(prompt_id);" )
0 commit comments