- Introduced `pyproject.toml` to centralize backend tool configurations (e.g., Ruff, mypy, coverage, pytest). - Replaced Black, isort, and Flake8 with Ruff for linting, formatting, and import sorting. - Updated `requirements.txt` to include Ruff and remove replaced tools. - Added `Makefile` to streamline development workflows with commands for linting, formatting, type-checking, testing, and cleanup.
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
# app/models/organization.py
|
|
from sqlalchemy import Boolean, Column, Index, String, Text
|
|
from sqlalchemy.dialects.postgresql import JSONB
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from .base import Base, TimestampMixin, UUIDMixin
|
|
|
|
|
|
class Organization(Base, UUIDMixin, TimestampMixin):
|
|
"""
|
|
Organization model for multi-tenant support.
|
|
Users can belong to multiple organizations with different roles.
|
|
"""
|
|
|
|
__tablename__ = "organizations"
|
|
|
|
name = Column(String(255), nullable=False, index=True)
|
|
slug = Column(String(255), unique=True, nullable=False, index=True)
|
|
description = Column(Text, nullable=True)
|
|
is_active = Column(Boolean, default=True, nullable=False, index=True)
|
|
settings = Column(JSONB, default={})
|
|
|
|
# Relationships
|
|
user_organizations = relationship(
|
|
"UserOrganization", back_populates="organization", cascade="all, delete-orphan"
|
|
)
|
|
|
|
__table_args__ = (
|
|
Index("ix_organizations_name_active", "name", "is_active"),
|
|
Index("ix_organizations_slug_active", "slug", "is_active"),
|
|
)
|
|
|
|
def __repr__(self):
|
|
return f"<Organization {self.name} ({self.slug})>"
|