Add weekly option on the schedule period
This commit is contained in:
parent
72974c90aa
commit
6f97b883fb
37
alembic/versions/e77395969585_weekly_period.py
Normal file
37
alembic/versions/e77395969585_weekly_period.py
Normal file
@ -0,0 +1,37 @@
|
||||
"""Weekly period
|
||||
|
||||
Revision ID: e77395969585
|
||||
Revises: d18cbd50f7c6
|
||||
Create Date: 2022-12-08 16:35:27.506504+00:00
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "e77395969585"
|
||||
down_revision = "d18cbd50f7c6"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.execute("ALTER TYPE transactions.period ADD VALUE 'weekly' AFTER 'daily'")
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.execute(
|
||||
"""CREATE TYPE transactions.period_new
|
||||
AS ENUM ('daily', 'monthly', 'yearly')
|
||||
"""
|
||||
)
|
||||
op.execute("UPDATE transactions.categories_schedules SET period = DEFAULT WHERE period = 'weekly'")
|
||||
op.execute(
|
||||
"""ALTER TABLE transactions.categories_schedules
|
||||
ALTER COLUMN period TYPE transactions.period_new
|
||||
USING period::text::transactions.period_new
|
||||
"""
|
||||
)
|
||||
op.execute("DROP TYPE transactions.period")
|
||||
op.execute("ALTER TYPE transactions.period_new RENAME TO period")
|
||||
@ -204,9 +204,10 @@ class CategorySelector(Base):
|
||||
|
||||
|
||||
class Period(enum.Enum):
|
||||
daily = enum.auto()
|
||||
monthly = enum.auto()
|
||||
yearly = enum.auto()
|
||||
daily = "daily"
|
||||
weekly = "weekly"
|
||||
monthly = "monthly"
|
||||
yearly = "yearly"
|
||||
|
||||
|
||||
scheduleperiod = Annotated[Selector, mapped_column(Enum(Period, inherit_schema=True))]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user