Skip to content
This repository has been archived by the owner on Feb 6, 2021. It is now read-only.

Add a runme.py file for creating the tables required by the bot #119

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions command.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
CREATE TABLE blacklist (
guild_ids bigint[] NOT NULL,
user_ids bigint[] NOT NULL
);


ALTER TABLE blacklist OWNER TO {owner};

CREATE TABLE dungeon (
guild_id bigint NOT NULL,
minimum_days integer NOT NULL,
dungeon_role_id bigint NOT NULL,
mod_status integer NOT NULL,
announcement_channel bigint NOT NULL,
mod_message text NOT NULL,
bypass_list bigint[] NOT NULL,
dungeon_status boolean NOT NULL
);


ALTER TABLE dungeon ADD CONSTRAINT unique_dungeon
UNIQUE (guild_id);

ALTER TABLE dungeon OWNER TO {owner};

CREATE TABLE lock (
guild_id bigint NOT NULL,
lock_state integer,
link_state integer
);


ALTER TABLE public.lock ALTER lock_state SET DEFAULT 0;
ALTER TABLE public.lock ALTER link_state SET DEFAULT 0;

ALTER TABLE lock ADD CONSTRAINT lock_unique
UNIQUE (guild_id);

ALTER TABLE lock OWNER TO {owner};

CREATE TABLE prefixes (
ctx_id bigint NOT NULL,
prefix text NOT NULL
);


ALTER TABLE prefixes ADD CONSTRAINT prefixes_unique
UNIQUE (ctx_id);

ALTER TABLE prefixes OWNER TO {owner};

CREATE TABLE smartreact (
guild_id bigint NOT NULL
);


ALTER TABLE smartreact ADD CONSTRAINT unique_smartreact
UNIQUE (guild_id);

ALTER TABLE smartreact OWNER TO {owner};

CREATE TABLE subscribe (
guild_id bigint NOT NULL,
role_id bigint NOT NULL
);


ALTER TABLE subscribe ADD CONSTRAINT unique_subscribe
UNIQUE (guild_id);

ALTER TABLE subscribe OWNER TO {owner};
31 changes: 31 additions & 0 deletions runme.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import asyncio

import asyncpg


async def main():
"""Create all the tables."""
username = input(
"Please enter the username of the PostgreSQL account: "
)
password = input(
"Please enter the password of the PostgreSQL account: "
)
database = input(
"Please enter the name of the database: "
)
con = await asyncpg.connect(
host="127.0.0.1",
user=username,
password=password,
database=database,
)
file = open("command.sql")
statement = file.read()
file.close()
await con.execute(
statement.format(owner=username)
)

if __name__ == "__main__":
asyncio.run(main())