Compare commits
No commits in common. "f91bc1b826933853e37c6a6b62bf97c174c08064" and "aa1e63080923d5f09c3e53930242176e2e0607bc" have entirely different histories.
f91bc1b826
...
aa1e630809
1 changed files with 0 additions and 26 deletions
|
|
@ -1,26 +0,0 @@
|
||||||
from sqlmodel import Session, create_engine, text
|
|
||||||
from database import DATABASE_URL
|
|
||||||
|
|
||||||
def add_reaction_table():
|
|
||||||
engine = create_engine(DATABASE_URL)
|
|
||||||
with Session(engine) as session:
|
|
||||||
try:
|
|
||||||
session.exec(text("""
|
|
||||||
CREATE TABLE IF NOT EXISTS reaction (
|
|
||||||
id SERIAL PRIMARY KEY,
|
|
||||||
user_id INTEGER NOT NULL REFERENCES "user"(id),
|
|
||||||
entity_type VARCHAR NOT NULL,
|
|
||||||
entity_id INTEGER NOT NULL,
|
|
||||||
emoji VARCHAR NOT NULL,
|
|
||||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
||||||
)
|
|
||||||
"""))
|
|
||||||
session.exec(text("CREATE INDEX IF NOT EXISTS ix_reaction_entity_type ON reaction (entity_type)"))
|
|
||||||
session.exec(text("CREATE INDEX IF NOT EXISTS ix_reaction_entity_id ON reaction (entity_id)"))
|
|
||||||
session.commit()
|
|
||||||
print("Successfully created reaction table")
|
|
||||||
except Exception as e:
|
|
||||||
print(f"Error creating table: {e}")
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
add_reaction_table()
|
|
||||||
Loading…
Add table
Reference in a new issue