32 lines
1.3 KiB
Python
32 lines
1.3 KiB
Python
"""operator fiscal context entries (facts the ERP does not know: role, origin, ST retention, treatment, ...)
|
|
|
|
Revision ID: 0011
|
|
Revises: 0010
|
|
"""
|
|
from alembic import op
|
|
from sqlalchemy import Column, DateTime, ForeignKey, Integer, String, Text, UniqueConstraint, func
|
|
|
|
revision = "0011"; down_revision = "0010"; branch_labels = depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
op.create_table(
|
|
"fiscal_context_entries",
|
|
Column("id", Integer, primary_key=True),
|
|
Column("tenant_id", Integer, ForeignKey("tenants.id"), nullable=False, index=True),
|
|
Column("company_key", String(64), nullable=False, index=True),
|
|
Column("scope", String(8), nullable=False),
|
|
Column("scope_key", String(64), nullable=False, server_default=""),
|
|
Column("key", String(48), nullable=False),
|
|
Column("value", Text, nullable=False),
|
|
Column("source", String(16), nullable=False, server_default="OPERATOR"),
|
|
Column("reason", Text, nullable=True),
|
|
Column("created_at", DateTime(timezone=True), server_default=func.now()),
|
|
Column("updated_at", DateTime(timezone=True), server_default=func.now()),
|
|
UniqueConstraint("tenant_id", "company_key", "scope", "scope_key", "key", name="uq_fiscal_context_entry"),
|
|
)
|
|
|
|
|
|
def downgrade():
|
|
op.drop_table("fiscal_context_entries")
|