Multi-tenancy : espaces de travail + fix auth reload (rate limiter OPTIONS)
- Modèles Organization + OrgMember, migration Alembic (SQLite compatible) - organization_id nullable sur Document, Decision, Mandate, VotingProtocol - Service, schéma, router /organizations + dependency get_active_org_id - Seed : Duniter G1 + Axiom Team ; tout le contenu seed attaché à Duniter G1 - Backend : list/create filtrés par header X-Organization - Frontend : store organizations, WorkspaceSelector réel, useApi injecte l'org - Fix critique : rate_limiter exclut les requêtes OPTIONS (CORS preflight) → résout le bug "Failed to fetch /auth/me" au reload (429 sur preflight) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -26,6 +26,8 @@ from app.database import Base
|
||||
from app.models import ( # noqa: F401
|
||||
DuniterIdentity,
|
||||
Session,
|
||||
Organization,
|
||||
OrgMember,
|
||||
Document,
|
||||
DocumentItem,
|
||||
ItemVersion,
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
"""add organizations
|
||||
|
||||
Revision ID: 70914b334cfb
|
||||
Revises:
|
||||
Create Date: 2026-04-23 12:27:56.220214+00:00
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision: str = '70914b334cfb'
|
||||
down_revision: Union[str, None] = None
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# SQLite does not support ADD CONSTRAINT via ALTER TABLE — FK constraints
|
||||
# are declared in models only; integrity is enforced at app layer.
|
||||
op.add_column('decisions', sa.Column('organization_id', sa.Uuid(), nullable=True))
|
||||
op.create_index(op.f('ix_decisions_organization_id'), 'decisions', ['organization_id'], unique=False)
|
||||
op.add_column('documents', sa.Column('organization_id', sa.Uuid(), nullable=True))
|
||||
op.create_index(op.f('ix_documents_organization_id'), 'documents', ['organization_id'], unique=False)
|
||||
op.add_column('mandates', sa.Column('organization_id', sa.Uuid(), nullable=True))
|
||||
op.create_index(op.f('ix_mandates_organization_id'), 'mandates', ['organization_id'], unique=False)
|
||||
op.add_column('voting_protocols', sa.Column('organization_id', sa.Uuid(), nullable=True))
|
||||
op.create_index(op.f('ix_voting_protocols_organization_id'), 'voting_protocols', ['organization_id'], unique=False)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_index(op.f('ix_voting_protocols_organization_id'), table_name='voting_protocols')
|
||||
op.drop_column('voting_protocols', 'organization_id')
|
||||
op.drop_index(op.f('ix_mandates_organization_id'), table_name='mandates')
|
||||
op.drop_column('mandates', 'organization_id')
|
||||
op.drop_index(op.f('ix_documents_organization_id'), table_name='documents')
|
||||
op.drop_column('documents', 'organization_id')
|
||||
op.drop_index(op.f('ix_decisions_organization_id'), table_name='decisions')
|
||||
op.drop_column('decisions', 'organization_id')
|
||||
Reference in New Issue
Block a user