- FastAPI app with lifespan, CORS, health endpoint - SQLAlchemy 2.0 async with aiosqlite, Base/UUIDMixin/TenantMixin/TimestampMixin - Tenant and User models with multi-tenant isolation - Auth: register (creates tenant+user), login, /me endpoint - JWT HS256 tokens, bcrypt password hashing - Alembic async setup with initial migration - 6 passing tests (register, login, wrong password, me, no token, health) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
19 lines
806 B
Python
19 lines
806 B
Python
from sqlalchemy import String, Text
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.db.base import Base, UUIDMixin, TimestampMixin
|
|
|
|
|
|
class Tenant(Base, UUIDMixin, TimestampMixin):
|
|
__tablename__ = "tenants"
|
|
nume: Mapped[str] = mapped_column(String(200))
|
|
cui: Mapped[str | None] = mapped_column(String(20))
|
|
reg_com: Mapped[str | None] = mapped_column(String(30))
|
|
adresa: Mapped[str | None] = mapped_column(Text)
|
|
telefon: Mapped[str | None] = mapped_column(String(20))
|
|
email: Mapped[str | None] = mapped_column(String(200))
|
|
iban: Mapped[str | None] = mapped_column(String(34))
|
|
banca: Mapped[str | None] = mapped_column(String(100))
|
|
plan: Mapped[str] = mapped_column(String(20), default="trial")
|
|
trial_expires_at: Mapped[str | None] = mapped_column(Text)
|