-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase_schema.py
More file actions
31 lines (25 loc) · 1.06 KB
/
database_schema.py
File metadata and controls
31 lines (25 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from sqlalchemy.engine import Engine
from sqlalchemy.ext.asyncio.engine import AsyncEngine
from sqlalchemy.schema import MetaData, Table, Column
from sqlalchemy.types import SmallInteger, BigInteger, String, Boolean
metadata = MetaData()
record_table = Table(
'record',
metadata,
Column('id', BigInteger, primary_key=True, nullable=False),
Column('feature_flags', SmallInteger, nullable=False),
Column('recheck', Boolean, nullable=False),
Column('target_submission_id', BigInteger, nullable=False),
Column('target_submission_created_ut', BigInteger, nullable=False),
Column('target_submission_author_name', String(24), nullable=False),
Column('bot_comment_id', BigInteger, nullable=True),
)
def create_database(engine: Engine) -> None:
metadata.create_all(engine)
async def create_database_async(engine: AsyncEngine) -> None:
async with engine.connect() as conn:
await conn.run_sync(metadata.create_all)
await conn.commit()