Skip to content

Commit 3d2f78f

Browse files
committed
refactor: separate migration for raw sql
1 parent 67866e5 commit 3d2f78f

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

botbase/piccolo_migrations/botbase_2023_05_23t00_19_45_350876.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -202,19 +202,4 @@ async def forwards():
202202
},
203203
)
204204

205-
async def composite_unique() -> None:
206-
class RawTable(Table):
207-
...
208-
209-
for _ in range(100):
210-
try:
211-
await RawTable.raw(
212-
"ALTER TABLE command_log "
213-
"ADD UNIQUE (command, guild, channel, member);"
214-
)
215-
except Exception:
216-
await asyncio.sleep(0.1)
217-
218-
manager.add_raw(partial(asyncio.create_task, composite_unique()))
219-
220205
return manager
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from piccolo.apps.migrations.auto.migration_manager import MigrationManager
2+
from piccolo.table import Table
3+
4+
5+
ID = "2023-05-23T00:48:52:721445"
6+
VERSION = "0.111.1"
7+
DESCRIPTION = "Add UNIQUE to CommandLog"
8+
9+
10+
async def forwards():
11+
manager = MigrationManager(migration_id=ID, app_name="", description=DESCRIPTION)
12+
13+
async def composite_unique() -> None:
14+
class RawTable(Table):
15+
...
16+
17+
await RawTable.raw(
18+
"ALTER TABLE command_log ADD UNIQUE (command, guild, channel, member);"
19+
)
20+
21+
manager.add_raw(composite_unique)
22+
23+
return manager

0 commit comments

Comments
 (0)