Transactions table (#7)
Tests / test (push) Successful in 10s
Tests / lint (push) Successful in 10s

Reviewed-on: #7
Co-authored-by: Mathias <mathias2784@web.de>
This commit was merged in pull request #7.
This commit is contained in:
2026-10-10 20:47:51 +00:00
committed by mathias2784
parent fdc66037ce
commit 6d98939024
17 changed files with 729 additions and 67 deletions
@@ -0,0 +1,60 @@
"""create transactions table
Revision ID: 78ec55b9e1d1
Revises: 8822a28b01ca
Create Date: 2026-10-10 16:32:10.691919
"""
from collections.abc import Sequence
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "78ec55b9e1d1"
down_revision: str | Sequence[str] | None = "8822a28b01ca"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None
def upgrade() -> None:
"""Upgrade schema."""
op.create_table(
"transactions",
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
sa.Column("hash_id", sa.String(), nullable=False),
sa.Column("source", sa.String(), nullable=False),
sa.Column("source_row_id", sa.Integer(), nullable=False),
sa.Column("account_iban", sa.String(), nullable=False),
sa.Column("account_currency", sa.String(length=3), nullable=False),
sa.Column("date_valid", sa.Date(), nullable=False),
sa.Column("date_book", sa.Date(), nullable=True),
sa.Column("amount", sa.Numeric(precision=12, scale=2), nullable=False),
sa.Column("amount_currency", sa.String(length=3), nullable=False),
sa.Column("text", sa.String(), nullable=True),
sa.Column("other_name", sa.String(), nullable=True),
sa.Column("other_iban", sa.String(), nullable=True),
sa.Column("category_id", sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(
["category_id"],
["category.id"],
),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("hash_id", name="uq_transactions_hash"),
)
op.create_index(
"ix_transactions_source_row_id",
"transactions",
["source", "source_row_id"],
unique=False,
)
# ### end Alembic commands ###
def downgrade() -> None:
"""Downgrade schema."""
op.drop_index("ix_transactions_source_row_id", table_name="transactions")
op.drop_table("transactions")
# ### end Alembic commands ###