47 lines
1.5 KiB
Python
47 lines
1.5 KiB
Python
from api.v1.common.base_models import TenantScopedMixin, TimestampMixin
|
|
from core.database import Base
|
|
from sqlalchemy import (
|
|
ForeignKeyConstraint,
|
|
Integer,
|
|
PrimaryKeyConstraint,
|
|
String,
|
|
UniqueConstraint,
|
|
)
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
|
|
class CountryRuleOct(Base, TenantScopedMixin, TimestampMixin):
|
|
__tablename__ = "country_rule_oct"
|
|
__table_args__ = (
|
|
PrimaryKeyConstraint("id", name="country_rule_oct_pkey"),
|
|
ForeignKeyConstraint(
|
|
["tenant_id", "company_id", "permission", "line", "fraction"],
|
|
[
|
|
"a76.fraction_rule_octave.tenant_id",
|
|
"a76.fraction_rule_octave.company_id",
|
|
"a76.fraction_rule_octave.permission",
|
|
"a76.fraction_rule_octave.line",
|
|
"a76.fraction_rule_octave.fraction",
|
|
],
|
|
ondelete="CASCADE",
|
|
name="fk_country_rule_oct_frac_octava",
|
|
),
|
|
UniqueConstraint(
|
|
"tenant_id",
|
|
"company_id",
|
|
"permission",
|
|
"line",
|
|
"fraction",
|
|
"country_code",
|
|
name="uq_country_rule_oct_permission_line_fraction_country",
|
|
),
|
|
{"schema": "a76"},
|
|
)
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
|
|
|
permission: Mapped[str] = mapped_column(String(20))
|
|
line: Mapped[int] = mapped_column()
|
|
fraction: Mapped[str] = mapped_column(String(10))
|
|
country_code: Mapped[str] = mapped_column(String(3))
|