21 lines
739 B
Python
21 lines
739 B
Python
from tortoise import connections
|
|
|
|
|
|
async def migrate():
|
|
conn = connections.get("default")
|
|
await conn.execute_script(
|
|
"""
|
|
CREATE TABLE IF NOT EXISTS share_code_reservations (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
code VARCHAR(255) NOT NULL UNIQUE,
|
|
file_code_id INT NULL,
|
|
reason VARCHAR(32) NOT NULL DEFAULT 'retired',
|
|
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
CREATE INDEX IF NOT EXISTS idx_share_code_reservations_code
|
|
ON share_code_reservations(code);
|
|
CREATE INDEX IF NOT EXISTS idx_share_code_reservations_file_code_id
|
|
ON share_code_reservations(file_code_id);
|
|
"""
|
|
)
|