1- from sqlalchemy import Column , String , Integer , JSON , LargeBinary , ForeignKey , DateTime , func
2- from sqlalchemy .orm import Mapped , mapped_column , relationship
1+ from __future__ import annotations
2+ from datetime import datetime
3+ from typing import Optional
4+
5+ from sqlalchemy import String , Integer , JSON , DateTime
6+ from sqlalchemy .orm import Mapped , mapped_column
7+
38from app .db import Base
49
510class DocumentRow (Base ):
611 __tablename__ = "documents"
12+
713 id : Mapped [int ] = mapped_column (Integer , primary_key = True , autoincrement = True )
814 doc_uid : Mapped [str ] = mapped_column (String (64 ), unique = True , index = True )
915 cdm : Mapped [dict ] = mapped_column (JSON )
10- schema_id : Mapped [str | None ] = mapped_column (String (64 ), nullable = True )
11- schema_version : Mapped [str | None ] = mapped_column (String (32 ), nullable = True )
12- created_at : Mapped = mapped_column (DateTime (timezone = True ), server_default = func .now ())
13- updated_at : Mapped = mapped_column (DateTime (timezone = True ), server_default = func .now (), onupdate = func .now ())
16+ schema_id : Mapped [Optional [str ]] = mapped_column (String (64 ), nullable = True )
17+ schema_version : Mapped [Optional [str ]] = mapped_column (String (32 ), nullable = True )
18+ created_at : Mapped [datetime ] = mapped_column (DateTime (timezone = True ))
19+ updated_at : Mapped [datetime ] = mapped_column (DateTime (timezone = True ))
20+
1421
1522class FileRow (Base ):
1623 __tablename__ = "files"
24+
1725 id : Mapped [int ] = mapped_column (Integer , primary_key = True , autoincrement = True )
1826 filename : Mapped [str ] = mapped_column (String (255 ))
1927 sha256 : Mapped [str ] = mapped_column (String (64 ), index = True )
2028 size : Mapped [int ] = mapped_column (Integer )
21- mime : Mapped [str | None ] = mapped_column (String (128 ), nullable = True )
22- meta : Mapped [dict | None ] = mapped_column (JSON , nullable = True )
23- created_at : Mapped = mapped_column (DateTime (timezone = True ), server_default = func . now ( ))
29+ mime : Mapped [Optional [ str ] ] = mapped_column (String (128 ), nullable = True )
30+ meta : Mapped [Optional [ dict ] ] = mapped_column (JSON , nullable = True )
31+ created_at : Mapped [ datetime ] = mapped_column (DateTime (timezone = True ))
2432
2533class RuleRow (Base ):
2634 __tablename__ = "rules"
35+
2736 id : Mapped [int ] = mapped_column (Integer , primary_key = True , autoincrement = True )
2837 rule_id : Mapped [str ] = mapped_column (String (128 ), unique = True , index = True )
2938 content : Mapped [dict ] = mapped_column (JSON )
30- version : Mapped [str | None ] = mapped_column (String (32 ), nullable = True )
31- created_at : Mapped = mapped_column (DateTime (timezone = True ), server_default = func . now ( ))
39+ version : Mapped [Optional [ str ] ] = mapped_column (String (32 ), nullable = True )
40+ created_at : Mapped [ datetime ] = mapped_column (DateTime (timezone = True ))
3241
3342class Schema (Base ):
3443 __tablename__ = "schemas"
3544
36- id = Column (Integer , primary_key = True , index = True )
37- name = Column (String , nullable = False )
38- version = Column (String , nullable = True )
39- namespace = Column (String , nullable = True )
40- description = Column (String , nullable = True )
41- file_path = Column (String , nullable = False )
42- created_at = Column (DateTime , nullable = False )
45+ id : Mapped [ int ] = mapped_column (Integer , primary_key = True , autoincrement = True )
46+ name : Mapped [ str ] = mapped_column (String , nullable = False )
47+ version : Mapped [ Optional [ str ]] = mapped_column (String , nullable = True )
48+ namespace : Mapped [ Optional [ str ]] = mapped_column (String , nullable = True )
49+ description : Mapped [ Optional [ str ]] = mapped_column (String , nullable = True )
50+ file_path : Mapped [ str ] = mapped_column (String , nullable = False )
51+ created_at : Mapped [ datetime ] = mapped_column (DateTime , nullable = False )
0 commit comments