Skip to content

Commit 7d1f375

Browse files
committed
refactor: set composite unique commandf_log
1 parent 01c6e63 commit 7d1f375

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

botbase/db/commands.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,3 @@ class CommandLog(Table):
1313
channel = BigInt()
1414
member = BigInt()
1515
amount = Integer(default=1)
16-
17-
18-
log.critical("Make sure to set command, guild, channel, member UNIQUE.")

botbase/piccolo_migrations/botbase_2023_05_23t00_19_45_350876.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
from piccolo.apps.migrations.auto.migration_manager import MigrationManager
2-
from piccolo.columns.column_types import BigInt
3-
from piccolo.columns.column_types import Integer
4-
from piccolo.columns.column_types import Text
2+
from piccolo.columns.column_types import BigInt, Integer, Text
53
from piccolo.columns.indexes import IndexMethod
6-
4+
from piccolo.table import Table
75

86
ID = "2023-05-23T00:19:45:350876"
97
VERSION = "0.111.1"
@@ -111,7 +109,7 @@ async def forwards():
111109
params={
112110
"default": "",
113111
"null": False,
114-
"primary_key": True,
112+
"primary_key": False,
115113
"unique": False,
116114
"index": False,
117115
"index_method": IndexMethod.btree,
@@ -201,4 +199,14 @@ async def forwards():
201199
},
202200
)
203201

202+
async def composite_unique() -> None:
203+
class RawTable(Table):
204+
...
205+
206+
await RawTable.raw(
207+
"ALTER TABLE command_log ADD UNIQUE (command, guild, channel, member);"
208+
)
209+
210+
manager.add_raw(composite_unique)
211+
204212
return manager

0 commit comments

Comments
 (0)