Files
infoscreen/server/alembic/versions/9b7a1f2a4d2b_add_school_holidays_table.py
olaf 41194000a4 feat: Add academic periods system for educational institutions
- Add AcademicPeriod model with support for schuljahr/semester/trimester
- Extend Event and EventMedia models with optional academic_period_id
- Create Alembic migration (8d1df7199cb7) for academic periods system
- Add init script for Austrian school year defaults (2024/25-2026/27)
- Maintain full backward compatibility for existing events/media
- Update program-info.json to version 2025.1.0-alpha.6

Database changes:
- New academic_periods table with unique name constraint
- Foreign key relationships with proper indexing
- Support for multiple period types with single active period

This lays the foundation for period-based organization of events
and media content, specifically designed for school environments
with future extensibility for universities.
2025-09-20 11:16:56 +00:00

48 lines
1.8 KiB
Python

"""add school holidays table
Revision ID: 9b7a1f2a4d2b
Revises: e6eaede720aa
Create Date: 2025-09-18 00:00:00.000000
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '9b7a1f2a4d2b'
down_revision = 'e6eaede720aa'
branch_labels = None
depends_on = None
def upgrade() -> None:
op.create_table(
'school_holidays',
sa.Column('id', sa.Integer(), primary_key=True, autoincrement=True),
sa.Column('name', sa.String(length=150), nullable=False),
sa.Column('start_date', sa.Date(), nullable=False),
sa.Column('end_date', sa.Date(), nullable=False),
sa.Column('region', sa.String(length=100), nullable=True),
sa.Column('source_file_name', sa.String(length=255), nullable=True),
sa.Column('imported_at', sa.TIMESTAMP(timezone=True),
server_default=sa.text('CURRENT_TIMESTAMP')),
)
op.create_index('ix_school_holidays_start_date',
'school_holidays', ['start_date'])
op.create_index('ix_school_holidays_end_date',
'school_holidays', ['end_date'])
op.create_index('ix_school_holidays_region', 'school_holidays', ['region'])
op.create_unique_constraint('uq_school_holidays_unique', 'school_holidays', [
'name', 'start_date', 'end_date', 'region'])
def downgrade() -> None:
op.drop_constraint('uq_school_holidays_unique',
'school_holidays', type_='unique')
op.drop_index('ix_school_holidays_region', table_name='school_holidays')
op.drop_index('ix_school_holidays_end_date', table_name='school_holidays')
op.drop_index('ix_school_holidays_start_date',
table_name='school_holidays')
op.drop_table('school_holidays')