diff --git a/database.py b/database.py index 5b3eb2b..680835b 100644 --- a/database.py +++ b/database.py @@ -291,8 +291,8 @@ async def minus_user_points(conn: connection, user_id: str, bet_value: int): cur.execute( "UPDATE member " "SET points = points - %s " - "WHERE user_id=%s", - (bet_value, user_id) + "WHERE user_id = %s AND points - %s >= 50", + (bet_value, user_id, bet_value) ) conn.commit() diff --git a/database.sql b/database.sql index f5d8435..aff685d 100644 --- a/database.sql +++ b/database.sql @@ -35,7 +35,7 @@ CREATE TABLE member user_id VARCHAR(255), guild_id VARCHAR(255), username VARCHAR(255), - points bigint DEFAULT 50 NOT NULL CHECK (points >= 50), + points bigint DEFAULT 50, bet_value bigint DEFAULT 50, PRIMARY KEY (user_id), FOREIGN KEY (guild_id) REFERENCES guild (guild_id)