1
Fork 0
mirror of https://github.com/wlinator/luminara.git synced 2024-10-02 18:23:12 +00:00

Fix migrations to avoid conflicts and replacing values

This commit is contained in:
wlinator 2024-08-01 10:09:54 -04:00
parent cf8058c46e
commit baac81c302
5 changed files with 22 additions and 22 deletions

View file

@ -1,6 +1,6 @@
TOKEN=
INSTANCE=
OWNER_IDS=
OWNER_ID=
XP_GAIN_PER_MESSAGE=
XP_GAIN_COOLDOWN=

View file

@ -1,6 +1,6 @@
SET FOREIGN_KEY_CHECKS=0;
CREATE TABLE xp (
CREATE TABLE IF NOT EXISTS xp (
user_id BIGINT NOT NULL,
guild_id BIGINT NOT NULL,
user_xp INT NOT NULL,
@ -9,13 +9,13 @@ CREATE TABLE xp (
PRIMARY KEY (user_id, guild_id)
);
CREATE TABLE currency (
CREATE TABLE IF NOT EXISTS currency (
user_id BIGINT NOT NULL,
balance BIGINT NOT NULL,
PRIMARY KEY (user_id)
);
CREATE TABLE blackjack (
CREATE TABLE IF NOT EXISTS blackjack (
id INT AUTO_INCREMENT,
user_id BIGINT,
is_won BOOLEAN,
@ -26,7 +26,7 @@ CREATE TABLE blackjack (
PRIMARY KEY (id)
);
CREATE TABLE slots (
CREATE TABLE IF NOT EXISTS slots (
id INT AUTO_INCREMENT,
user_id BIGINT,
is_won BOOLEAN,
@ -37,7 +37,7 @@ CREATE TABLE slots (
PRIMARY KEY (id)
);
CREATE TABLE dailies (
CREATE TABLE IF NOT EXISTS dailies (
id INT AUTO_INCREMENT,
user_id BIGINT,
amount BIGINT,
@ -46,7 +46,7 @@ CREATE TABLE dailies (
PRIMARY KEY (id)
);
CREATE TABLE item (
CREATE TABLE IF NOT EXISTS item (
id INT AUTO_INCREMENT,
name TEXT,
display_name TEXT,
@ -58,7 +58,7 @@ CREATE TABLE item (
PRIMARY KEY (id)
);
CREATE TABLE inventory (
CREATE TABLE IF NOT EXISTS inventory (
user_id BIGINT,
item_id INT,
quantity INT,
@ -67,14 +67,14 @@ CREATE TABLE inventory (
FOREIGN KEY (item_id) REFERENCES item (id)
);
CREATE TABLE birthdays (
CREATE TABLE IF NOT EXISTS birthdays (
user_id BIGINT NOT NULL,
guild_id BIGINT NOT NULL,
birthday DATETIME DEFAULT NULL,
PRIMARY KEY (user_id, guild_id)
);
CREATE TABLE guild_config (
CREATE TABLE IF NOT EXISTS guild_config (
guild_id BIGINT NOT NULL,
prefix TINYTEXT,
birthday_channel_id BIGINT,
@ -91,7 +91,7 @@ CREATE TABLE guild_config (
PRIMARY KEY (guild_id)
);
CREATE TABLE level_rewards (
CREATE TABLE IF NOT EXISTS level_rewards (
guild_id BIGINT NOT NULL,
level INT NOT NULL,
role_id BIGINT,
@ -100,7 +100,7 @@ CREATE TABLE level_rewards (
PRIMARY KEY (guild_id, level)
);
CREATE TABLE blacklist_user (
CREATE TABLE IF NOT EXISTS blacklist_user (
user_id BIGINT NOT NULL,
reason TEXT,
timestamp TIMESTAMP NOT NULL DEFAULT NOW(),

View file

@ -1,5 +1,5 @@
-- Create a table to store custom reactions
CREATE TABLE custom_reactions (
CREATE TABLE IF NOT EXISTS custom_reactions (
id SERIAL PRIMARY KEY, -- Unique identifier for each custom reaction
trigger_text TEXT NOT NULL, -- The text that triggers the custom reaction
response TEXT, -- The response text for the custom reaction (nullable for emoji reactions)
@ -16,6 +16,6 @@ CREATE TABLE custom_reactions (
);
-- Create indexes to speed up lookups
CREATE INDEX idx_custom_reactions_guild_id ON custom_reactions(guild_id);
CREATE INDEX idx_custom_reactions_creator_id ON custom_reactions(creator_id);
CREATE INDEX idx_custom_reactions_trigger_text ON custom_reactions(trigger_text);
CREATE OR REPLACE INDEX idx_custom_reactions_guild_id ON custom_reactions(guild_id);
CREATE OR REPLACE INDEX idx_custom_reactions_creator_id ON custom_reactions(creator_id);
CREATE OR REPLACE INDEX idx_custom_reactions_trigger_text ON custom_reactions(trigger_text);

View file

@ -39,7 +39,7 @@ CREATE TABLE IF NOT EXISTS cases (
);
CREATE INDEX idx_cases_guild_id ON cases(guild_id);
CREATE INDEX idx_cases_target_id ON cases(target_id);
CREATE INDEX idx_cases_moderator_id ON cases(moderator_id);
CREATE INDEX idx_cases_action_type ON cases(action_type);
CREATE OR REPLACE INDEX idx_cases_guild_id ON cases(guild_id);
CREATE OR REPLACE INDEX idx_cases_target_id ON cases(target_id);
CREATE OR REPLACE INDEX idx_cases_moderator_id ON cases(moderator_id);
CREATE OR REPLACE INDEX idx_cases_action_type ON cases(action_type);

View file

@ -19,8 +19,8 @@ class Constants:
INSTANCE: Optional[str] = os.environ.get("INSTANCE", None)
OWNER_IDS: Optional[Set[int]] = (
{int(id.strip()) for id in os.environ.get("OWNER_IDS", "").split(",") if id}
if os.environ.get("OWNER_IDS")
{int(id.strip()) for id in os.environ.get("OWNER_ID", "").split(",") if id}
if os.environ.get("OWNER_ID")
else None
)