1
0

initialise_database.py 755 B

12345
  1. async def init_db(pg):
  2. await pg.execute("CREATE TABLE IF NOT EXISTS guild (id SERIAL PRIMARY KEY, guild_id BIGINT UNIQUE NOT NULL)")
  3. await pg.execute("CREATE TABLE IF NOT EXISTS channel (id SERIAL PRIMARY KEY, channel_id BIGINT UNIQUE NOT NULL, guild BIGINT REFERENCES guild (guild_id))")
  4. await pg.execute("CREATE TABLE IF NOT EXISTS channel_settings (id SERIAL PRIMARY KEY, channel BIGINT UNIQUE NOT NULL REFERENCES channel (channel_id), guild BIGINT REFERENCES guild (guild_id), interact BOOL DEFAULT FALSE)")
  5. await pg.execute("CREATE TABLE IF NOT EXISTS channel_user (id SERIAL PRIMARY KEY, channel BIGINT NOT NULL REFERENCES channel (channel_id), \"user\" BIGINT NOT NULL, total_messages BIGINT DEFAULT 1, UNIQUE (channel, \"user\"))")