mirror of
https://github.com/Hestia-Homes/survey-extraction.git
synced 2026-06-08 11:17:29 +00:00
fix some stuff
This commit is contained in:
parent
812f540f68
commit
5e7ee82c6c
2 changed files with 33 additions and 17 deletions
|
|
@ -33,6 +33,8 @@ def run_migrations_offline() -> None:
|
|||
target_metadata=target_metadata,
|
||||
literal_binds=True,
|
||||
dialect_opts={"paramstyle": "named"},
|
||||
compare_type=True,
|
||||
compare_server_default=True,
|
||||
)
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
|
|
|||
|
|
@ -1,15 +1,25 @@
|
|||
from sqlmodel import Field, SQLModel, Relationship
|
||||
from sqlmodel import Field, SQLModel, Relationship, Column, text
|
||||
import uuid
|
||||
from typing import Optional, List
|
||||
from datetime import datetime
|
||||
from pydantic import EmailStr
|
||||
from sqlalchemy import Enum as SAEnum
|
||||
from sqlalchemy import Column
|
||||
from sqlalchemy.dialects.postgresql import UUID
|
||||
from etl.fileReader.reportType import ReportType
|
||||
from sqlalchemy import DateTime
|
||||
|
||||
class BaseModel(SQLModel):
|
||||
id: uuid.UUID = Field(default_factory=uuid.uuid4, primary_key=True)
|
||||
|
||||
# Put primary_key=True in Column; don't pass primary_key to Field
|
||||
id: uuid.UUID = Field(
|
||||
sa_column=Column(
|
||||
UUID(as_uuid=True),
|
||||
primary_key=True,
|
||||
server_default=text("gen_random_uuid()"), # or: text("uuid_generate_v4()")
|
||||
nullable=False,
|
||||
)
|
||||
)
|
||||
|
||||
# class Buildings(BaseModel, table=True):
|
||||
# address: str
|
||||
# postcode: str
|
||||
|
|
@ -44,23 +54,27 @@ class BaseModel(SQLModel):
|
|||
# DOMNA_CONDITION_PAS_2035_REPORT = "DOMNA_CONDITION_PAS_2035_REPORT"
|
||||
|
||||
class uploaded_files(BaseModel, table=True):
|
||||
__tablename__ = "uploaded_files" # keeps it simple/snake_case
|
||||
__tablename__ = "uploaded_files"
|
||||
|
||||
# URIs
|
||||
s3_json_uri: Optional[str] = None
|
||||
s3_file_uri: str = Field(index=True) # index helps lookups; make unique in migrations if needed
|
||||
s3_file_uri: str = Field(index=True)
|
||||
|
||||
# Document type (uses your enum)
|
||||
doc_type: ReportType
|
||||
|
||||
# Timestamps
|
||||
s3_file_upload_timestamp: datetime = Field(
|
||||
default_factory=datetime.utcnow, nullable=False
|
||||
doc_type: ReportType = Field(
|
||||
sa_column=Column(
|
||||
SAEnum(ReportType, name="reporttype", native_enum=True, create_type=False, validate_strings=True),
|
||||
nullable=False,
|
||||
)
|
||||
)
|
||||
|
||||
s3_file_upload_timestamp: datetime = Field(
|
||||
sa_column=Column(
|
||||
DateTime(timezone=True),
|
||||
server_default=text("NOW() AT TIME ZONE 'utc'"),
|
||||
nullable=False,
|
||||
)
|
||||
)
|
||||
s3_json_upload_timestamp: Optional[datetime] = Field(
|
||||
sa_column=Column(DateTime(timezone=True), nullable=True)
|
||||
)
|
||||
s3_json_upload_timestamp: Optional[datetime] = None
|
||||
|
||||
# UPRN
|
||||
uprn: str = Field(index=True)
|
||||
|
||||
# Documents.update_forward_refs()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue