Changes recurring categories boolean to int
to indicate the number of expected transactions per time period.
This commit is contained in:
parent
f721e6a910
commit
fed007ff89
@ -0,0 +1,38 @@
|
|||||||
|
"""Amount of transaction per period
|
||||||
|
|
||||||
|
Revision ID: 83603bb7ef9c
|
||||||
|
Revises: 8b5d5fbc8211
|
||||||
|
Create Date: 2022-12-09 23:12:15.644758+00:00
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = "83603bb7ef9c"
|
||||||
|
down_revision = "8b5d5fbc8211"
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.add_column(
|
||||||
|
"categories_schedules",
|
||||||
|
sa.Column("amount", sa.Integer(), nullable=True),
|
||||||
|
schema="transactions",
|
||||||
|
)
|
||||||
|
op.drop_column("categories_schedules", "recurring", schema="transactions")
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.add_column(
|
||||||
|
"categories_schedules",
|
||||||
|
sa.Column("recurring", sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||||
|
schema="transactions",
|
||||||
|
)
|
||||||
|
op.drop_column("categories_schedules", "amount", schema="transactions")
|
||||||
|
# ### end Alembic commands ###
|
||||||
@ -231,15 +231,11 @@ class CategorySchedule(Base):
|
|||||||
__tablename__ = "categories_schedules"
|
__tablename__ = "categories_schedules"
|
||||||
|
|
||||||
name: Mapped[catfk] = mapped_column(primary_key=True)
|
name: Mapped[catfk] = mapped_column(primary_key=True)
|
||||||
recurring: Mapped[bool]
|
|
||||||
period: Mapped[Optional[scheduleperiod]]
|
period: Mapped[Optional[scheduleperiod]]
|
||||||
period_multiplier: Mapped[Optional[int]]
|
period_multiplier: Mapped[Optional[int]]
|
||||||
|
amount: Mapped[Optional[int]]
|
||||||
|
|
||||||
category: Mapped[Category] = relationship(back_populates="schedule")
|
category: Mapped[Category] = relationship(back_populates="schedule")
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return (
|
return f"{self.name} schedule=Schedule(period={self.period}, multiplier={self.period_multiplier}, amount={self.amount})"
|
||||||
f"{self.name} schedule=Schedule(period={self.period}, multiplier={self.period_multiplier})"
|
|
||||||
if self.recurring
|
|
||||||
else f"{self.name} has no Schedule"
|
|
||||||
)
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user