From 6b60c377265566f30532784039c1a646d7c07b40 Mon Sep 17 00:00:00 2001 From: imcompiling Date: Wed, 16 Jul 2025 10:26:33 -0400 Subject: [PATCH] Fix: errors on models from generating database. --- dakiny_bot/database/db.py | 1 - dakiny_bot/database/models.py | 10 +++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/dakiny_bot/database/db.py b/dakiny_bot/database/db.py index b97cf18..1473720 100644 --- a/dakiny_bot/database/db.py +++ b/dakiny_bot/database/db.py @@ -10,5 +10,4 @@ url = "sqlite:///database/dakiny.db" dakiny_logger.info("Connected to local dev database.") engine = create_engine(url) -# Don't need to create all when connected to prod. SQLModel.metadata.create_all(engine) diff --git a/dakiny_bot/database/models.py b/dakiny_bot/database/models.py index 5f8a937..62b9995 100644 --- a/dakiny_bot/database/models.py +++ b/dakiny_bot/database/models.py @@ -19,6 +19,8 @@ class ElectionInformation(SQLModel, table=True): votes: All votes cast during this election. """ + __tablename__: str = "ElectionInformation" + name: str = Field(sa_column=Column("ElectionName", VARCHAR, primary_key=True, unique=True), max_length=30) thread_id: int = Field(sa_column=Column("ThreadId", BIGINT(unsigned=True), nullable=False)) council_vote_msg_id: int | None = Field( @@ -109,9 +111,11 @@ class Vote(SQLModel, table=True): voter_id: int = Field(sa_column=Column("VoterId", BIGINT(unsigned=True), primary_key=True, nullable=False)) # might have to set this foreign key later with alembic migration... voted_for_id: int | None = Field( - sa_column=Column("VotedForId", BIGINT(unsigned=True), ForeignKey("CouncilMembers.member_id"), nullable=True) + sa_column=Column("VotedForId", BIGINT(unsigned=True), ForeignKey("CouncilMembers.MemberId"), nullable=True) + ) + type: str = Field( + sa_column=Column("Type", VARCHAR, primary_key=True, nullable=False, default="council"), max_length=14 ) - type: str = Field(sa_column=Column("Type", primary_key=True, nullable=False, default="council"), max_length=14) election: ElectionInformation | None = Relationship(back_populates="votes") council_member: CouncilMember | None = Relationship(back_populates="votes") @@ -184,7 +188,7 @@ class Message(SQLModel, table=True): __tablename__: str = "Messages" - path: str = Field(sa_column=Column("Path", primary_key=True, nullable=False), max_length=100) + path: str = Field(sa_column=Column("Path", VARCHAR, primary_key=True, nullable=False), max_length=100) id: int = Field(sa_column=Column("Id", BIGINT(unsigned=True), nullable=False))