-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
CREATE TABLE reports ( | ||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | ||
reporter_id INT NOT NULL, | ||
reported_user_id INT NOT NULL, | ||
chat_id BIGINT NOT NULL, | ||
created_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, | ||
resolution_time TIMESTAMP, | ||
reported_message_id BIGINT NOT NULL, | ||
reported_message_content VARCHAR(4096) NOT NULL, | ||
resolved_by_id INT, | ||
status varchar(32) NOT NULL, | ||
|
||
|
||
CONSTRAINT reports_reporter_FK FOREIGN KEY (reporter_id) REFERENCES users(id), | ||
CONSTRAINT reports_reported_user_FK FOREIGN KEY (reported_user_id) REFERENCES users(id), | ||
CONSTRAINT reports_chat_FK FOREIGN KEY (chat_id) REFERENCES chats(chat_id), | ||
CONSTRAINT reports_resolved_by_FK FOREIGN KEY (resolved_by_id) REFERENCES users(id) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import sqlite3 | ||
import sys | ||
from pathlib import Path | ||
|
||
from app.config import load_config | ||
|
||
|
||
db_config = load_config().db | ||
|
||
with (Path(__file__).parent / sys.argv[1]).open() as f: | ||
sql = f.read() | ||
|
||
with sqlite3.connect(db_config.db_path) as conn: | ||
cur = conn.cursor() | ||
cur.execute(sql) |