Initial commit: SejeteralO water tarification platform
Full-stack app for participatory water pricing using Bezier curves. - Backend: FastAPI + SQLAlchemy + SQLite with JWT auth - Frontend: Nuxt 4 + TypeScript with interactive SVG editor - Math engine: cubic Bezier tarification with Cardano solver - Admin: commune management, household import, vote monitoring, CMS - Citizen: interactive curve editor, vote submission - Docker-compose deployment ready Includes fixes for: - Impact table snake_case/camelCase property mismatch - CMS content backend API + frontend editor (was stub) - Admin route protection middleware - Public content display on commune page - Vote confirmation page link fix Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
130
backend/alembic/versions/25f534648ea7_initial_schema.py
Normal file
130
backend/alembic/versions/25f534648ea7_initial_schema.py
Normal file
@@ -0,0 +1,130 @@
|
||||
"""initial schema
|
||||
|
||||
Revision ID: 25f534648ea7
|
||||
Revises:
|
||||
Create Date: 2026-02-21 05:29:28.228738
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '25f534648ea7'
|
||||
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:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('admin_users',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('email', sa.String(length=200), nullable=False),
|
||||
sa.Column('hashed_password', sa.String(length=200), nullable=False),
|
||||
sa.Column('full_name', sa.String(length=200), nullable=True),
|
||||
sa.Column('role', sa.String(length=20), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_admin_users_email'), 'admin_users', ['email'], unique=True)
|
||||
op.create_index(op.f('ix_admin_users_id'), 'admin_users', ['id'], unique=False)
|
||||
op.create_table('communes',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('name', sa.String(length=200), nullable=False),
|
||||
sa.Column('slug', sa.String(length=200), nullable=False),
|
||||
sa.Column('description', sa.Text(), nullable=True),
|
||||
sa.Column('is_active', sa.Boolean(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_communes_id'), 'communes', ['id'], unique=False)
|
||||
op.create_index(op.f('ix_communes_slug'), 'communes', ['slug'], unique=True)
|
||||
op.create_table('admin_commune',
|
||||
sa.Column('admin_id', sa.Integer(), nullable=False),
|
||||
sa.Column('commune_id', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['admin_id'], ['admin_users.id'], ),
|
||||
sa.ForeignKeyConstraint(['commune_id'], ['communes.id'], ),
|
||||
sa.PrimaryKeyConstraint('admin_id', 'commune_id')
|
||||
)
|
||||
op.create_table('commune_contents',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('commune_id', sa.Integer(), nullable=False),
|
||||
sa.Column('slug', sa.String(length=200), nullable=False),
|
||||
sa.Column('title', sa.String(length=200), nullable=True),
|
||||
sa.Column('body_markdown', sa.Text(), nullable=True),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['commune_id'], ['communes.id'], ),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('commune_id', 'slug', name='uq_content_commune_slug')
|
||||
)
|
||||
op.create_index(op.f('ix_commune_contents_id'), 'commune_contents', ['id'], unique=False)
|
||||
op.create_table('households',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('commune_id', sa.Integer(), nullable=False),
|
||||
sa.Column('identifier', sa.String(length=200), nullable=False),
|
||||
sa.Column('status', sa.String(length=10), nullable=False),
|
||||
sa.Column('volume_m3', sa.Float(), nullable=False),
|
||||
sa.Column('price_paid_eur', sa.Float(), nullable=True),
|
||||
sa.Column('auth_code', sa.String(length=8), nullable=False),
|
||||
sa.Column('has_voted', sa.Boolean(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['commune_id'], ['communes.id'], ),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('commune_id', 'identifier', name='uq_household_commune_identifier')
|
||||
)
|
||||
op.create_index(op.f('ix_households_auth_code'), 'households', ['auth_code'], unique=True)
|
||||
op.create_index(op.f('ix_households_id'), 'households', ['id'], unique=False)
|
||||
op.create_table('tariff_params',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('commune_id', sa.Integer(), nullable=False),
|
||||
sa.Column('abop', sa.Float(), nullable=True),
|
||||
sa.Column('abos', sa.Float(), nullable=True),
|
||||
sa.Column('recettes', sa.Float(), nullable=True),
|
||||
sa.Column('pmax', sa.Float(), nullable=True),
|
||||
sa.Column('vmax', sa.Float(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['commune_id'], ['communes.id'], ),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('commune_id')
|
||||
)
|
||||
op.create_index(op.f('ix_tariff_params_id'), 'tariff_params', ['id'], unique=False)
|
||||
op.create_table('votes',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('commune_id', sa.Integer(), nullable=False),
|
||||
sa.Column('household_id', sa.Integer(), nullable=False),
|
||||
sa.Column('vinf', sa.Float(), nullable=False),
|
||||
sa.Column('a', sa.Float(), nullable=False),
|
||||
sa.Column('b', sa.Float(), nullable=False),
|
||||
sa.Column('c', sa.Float(), nullable=False),
|
||||
sa.Column('d', sa.Float(), nullable=False),
|
||||
sa.Column('e', sa.Float(), nullable=False),
|
||||
sa.Column('computed_p0', sa.Float(), nullable=True),
|
||||
sa.Column('submitted_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('is_active', sa.Boolean(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['commune_id'], ['communes.id'], ),
|
||||
sa.ForeignKeyConstraint(['household_id'], ['households.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_votes_id'), 'votes', ['id'], unique=False)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f('ix_votes_id'), table_name='votes')
|
||||
op.drop_table('votes')
|
||||
op.drop_index(op.f('ix_tariff_params_id'), table_name='tariff_params')
|
||||
op.drop_table('tariff_params')
|
||||
op.drop_index(op.f('ix_households_id'), table_name='households')
|
||||
op.drop_index(op.f('ix_households_auth_code'), table_name='households')
|
||||
op.drop_table('households')
|
||||
op.drop_index(op.f('ix_commune_contents_id'), table_name='commune_contents')
|
||||
op.drop_table('commune_contents')
|
||||
op.drop_table('admin_commune')
|
||||
op.drop_index(op.f('ix_communes_slug'), table_name='communes')
|
||||
op.drop_index(op.f('ix_communes_id'), table_name='communes')
|
||||
op.drop_table('communes')
|
||||
op.drop_index(op.f('ix_admin_users_id'), table_name='admin_users')
|
||||
op.drop_index(op.f('ix_admin_users_email'), table_name='admin_users')
|
||||
op.drop_table('admin_users')
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user