43 lines
1.6 KiB
Python
43 lines
1.6 KiB
Python
|
|
"""Create tax_rates table.
|
||
|
|
|
||
|
|
Revision ID: 0008_tax_rates
|
||
|
|
Revises: 0007_currencies
|
||
|
|
Create Date: 2026-07-04
|
||
|
|
"""
|
||
|
|
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from typing import Sequence, Union
|
||
|
|
|
||
|
|
from alembic import op
|
||
|
|
import sqlalchemy as sa
|
||
|
|
from sqlalchemy.dialects import postgresql
|
||
|
|
|
||
|
|
revision: str = "0008_tax_rates"
|
||
|
|
down_revision: Union[str, None] = "0007_currencies"
|
||
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
||
|
|
depends_on: Union[str, Sequence[str], None] = None
|
||
|
|
|
||
|
|
|
||
|
|
def upgrade() -> None:
|
||
|
|
op.create_table(
|
||
|
|
"tax_rates",
|
||
|
|
sa.Column("id", postgresql.UUID(as_uuid=True), primary_key=True),
|
||
|
|
sa.Column("name", sa.String(100), nullable=False),
|
||
|
|
sa.Column("rate", sa.Numeric(5, 2), nullable=False),
|
||
|
|
sa.Column("is_default", sa.Boolean, nullable=False, server_default="false"),
|
||
|
|
sa.Column("country", sa.String(2), nullable=True),
|
||
|
|
sa.Column("tenant_id", postgresql.UUID(as_uuid=True), nullable=False, index=True),
|
||
|
|
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False, server_default=sa.func.now()),
|
||
|
|
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=False, server_default=sa.func.now()),
|
||
|
|
sa.Column("deleted_at", sa.DateTime(timezone=True), nullable=True),
|
||
|
|
)
|
||
|
|
op.create_index("ix_tax_rates_tenant_name", "tax_rates", ["tenant_id", "name"])
|
||
|
|
op.create_index("ix_tax_rates_tenant_default", "tax_rates", ["tenant_id", "is_default"])
|
||
|
|
|
||
|
|
|
||
|
|
def downgrade() -> None:
|
||
|
|
op.drop_index("ix_tax_rates_tenant_default", table_name="tax_rates")
|
||
|
|
op.drop_index("ix_tax_rates_tenant_name", table_name="tax_rates")
|
||
|
|
op.drop_table("tax_rates")
|