Move selector table back to transactions schema
Change table name originals to transactions and tags to tagged.
This commit is contained in:
parent
ae0a195069
commit
ace5195164
@ -0,0 +1,88 @@
|
|||||||
|
"""Selector back to transaction
|
||||||
|
|
||||||
|
Revision ID: 28556ab17c56
|
||||||
|
Revises: e455c78df789
|
||||||
|
Create Date: 2023-01-23 00:34:39.062562+00:00
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy.dialects import postgresql
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = "28556ab17c56"
|
||||||
|
down_revision = "e455c78df789"
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.rename_table("tags", "tagged", schema="transactions")
|
||||||
|
op.create_table(
|
||||||
|
"selector",
|
||||||
|
sa.Column("id", sa.BigInteger(), nullable=False),
|
||||||
|
sa.Column(
|
||||||
|
"selector",
|
||||||
|
sa.Enum(
|
||||||
|
"unknown",
|
||||||
|
"nullifier",
|
||||||
|
"vacations",
|
||||||
|
"rules",
|
||||||
|
"algorithm",
|
||||||
|
"manual",
|
||||||
|
name="selector_t",
|
||||||
|
schema="transactions",
|
||||||
|
inherit_schema=True,
|
||||||
|
),
|
||||||
|
nullable=False,
|
||||||
|
),
|
||||||
|
sa.ForeignKeyConstraint(
|
||||||
|
["id"],
|
||||||
|
["transactions.categorized.id"],
|
||||||
|
name=op.f("fk_selector_id_categorized"),
|
||||||
|
ondelete="CASCADE",
|
||||||
|
),
|
||||||
|
sa.PrimaryKeyConstraint("id", name=op.f("pk_selector")),
|
||||||
|
schema="transactions",
|
||||||
|
)
|
||||||
|
op.drop_table("selector", schema="category")
|
||||||
|
|
||||||
|
op.rename_table("originals", "transactions", schema="transactions")
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.rename_table("transactions", "originals", schema="transactions")
|
||||||
|
|
||||||
|
op.create_table(
|
||||||
|
"selector",
|
||||||
|
sa.Column("id", sa.BIGINT(), autoincrement=False, nullable=False),
|
||||||
|
sa.Column(
|
||||||
|
"selector",
|
||||||
|
postgresql.ENUM(
|
||||||
|
"unknown",
|
||||||
|
"nullifier",
|
||||||
|
"vacations",
|
||||||
|
"rules",
|
||||||
|
"algorithm",
|
||||||
|
"manual",
|
||||||
|
name="selector_t",
|
||||||
|
schema="category",
|
||||||
|
),
|
||||||
|
autoincrement=False,
|
||||||
|
nullable=False,
|
||||||
|
),
|
||||||
|
sa.ForeignKeyConstraint(
|
||||||
|
["id"],
|
||||||
|
["transactions.categorized.id"],
|
||||||
|
name="fk_selector_id_categorized",
|
||||||
|
ondelete="CASCADE",
|
||||||
|
),
|
||||||
|
sa.PrimaryKeyConstraint("id", name="pk_selector"),
|
||||||
|
schema="category",
|
||||||
|
)
|
||||||
|
op.drop_table("selector", schema="transactions")
|
||||||
|
op.rename_table("tagged", "tags", schema="transactions")
|
||||||
|
# ### end Alembic commands ###
|
||||||
@ -84,7 +84,7 @@ money = Annotated[decimal.Decimal, mapped_column(Numeric(16, 2))]
|
|||||||
|
|
||||||
|
|
||||||
class Transaction(Base, Export):
|
class Transaction(Base, Export):
|
||||||
__tablename__ = "originals"
|
__tablename__ = "transactions"
|
||||||
|
|
||||||
id: Mapped[idpk] = mapped_column(init=False)
|
id: Mapped[idpk] = mapped_column(init=False)
|
||||||
date: Mapped[dt.date]
|
date: Mapped[dt.date]
|
||||||
@ -246,7 +246,7 @@ class Tag(Base):
|
|||||||
|
|
||||||
|
|
||||||
class TransactionTag(Base, Export):
|
class TransactionTag(Base, Export):
|
||||||
__tablename__ = "tags"
|
__tablename__ = "tagged"
|
||||||
|
|
||||||
id: Mapped[idfk] = mapped_column(primary_key=True, init=False)
|
id: Mapped[idfk] = mapped_column(primary_key=True, init=False)
|
||||||
tag: Mapped[str] = mapped_column(ForeignKey(Tag.name), primary_key=True)
|
tag: Mapped[str] = mapped_column(ForeignKey(Tag.name), primary_key=True)
|
||||||
@ -275,7 +275,6 @@ categoryselector = Annotated[
|
|||||||
|
|
||||||
|
|
||||||
class CategorySelector(Base, Export):
|
class CategorySelector(Base, Export):
|
||||||
__table_args__ = {"schema": "category"}
|
|
||||||
__tablename__ = "selector"
|
__tablename__ = "selector"
|
||||||
|
|
||||||
id: Mapped[int] = mapped_column(
|
id: Mapped[int] = mapped_column(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user