Initial commit - copied workspace after database cleanup
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
"""Rename location to description in client_groups, add description to clients
|
||||
|
||||
Revision ID: 0c47280d3e2d
|
||||
Revises: 3a09ef909689
|
||||
Create Date: 2025-07-16 08:47:00.355445
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '0c47280d3e2d'
|
||||
down_revision: Union[str, None] = '3a09ef909689'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('client_groups', sa.Column('description', sa.String(length=255), nullable=True))
|
||||
op.drop_column('client_groups', 'location')
|
||||
op.add_column('clients', sa.Column('description', sa.String(length=255), nullable=True))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('clients', 'description')
|
||||
op.add_column('client_groups', sa.Column('location', mysql.VARCHAR(length=100), nullable=True))
|
||||
op.drop_column('client_groups', 'description')
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,56 @@
|
||||
"""Update clients table for new fields
|
||||
|
||||
Revision ID: 207f5b190f93
|
||||
Revises: 3d15c3cac7b6
|
||||
Create Date: 2025-07-15 14:12:42.427274
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '207f5b190f93'
|
||||
down_revision: Union[str, None] = '3d15c3cac7b6'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('clients', sa.Column('hardware_token', sa.String(length=64), nullable=True))
|
||||
op.add_column('clients', sa.Column('ip', sa.String(length=45), nullable=True))
|
||||
op.add_column('clients', sa.Column('type', sa.String(length=50), nullable=True))
|
||||
op.add_column('clients', sa.Column('hostname', sa.String(length=100), nullable=True))
|
||||
op.add_column('clients', sa.Column('os_version', sa.String(length=100), nullable=True))
|
||||
op.add_column('clients', sa.Column('software_version', sa.String(length=100), nullable=True))
|
||||
op.add_column('clients', sa.Column('macs', sa.String(length=255), nullable=True))
|
||||
op.add_column('clients', sa.Column('model', sa.String(length=100), nullable=True))
|
||||
op.drop_index(op.f('ix_clients_hardware_hash'), table_name='clients')
|
||||
op.drop_index(op.f('ix_clients_ip_address'), table_name='clients')
|
||||
op.drop_column('clients', 'location')
|
||||
op.drop_column('clients', 'hardware_hash')
|
||||
op.drop_column('clients', 'ip_address')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('clients', sa.Column('ip_address', mysql.VARCHAR(length=45), nullable=True))
|
||||
op.add_column('clients', sa.Column('hardware_hash', mysql.VARCHAR(length=64), nullable=False))
|
||||
op.add_column('clients', sa.Column('location', mysql.VARCHAR(length=100), nullable=True))
|
||||
op.create_index(op.f('ix_clients_ip_address'), 'clients', ['ip_address'], unique=False)
|
||||
op.create_index(op.f('ix_clients_hardware_hash'), 'clients', ['hardware_hash'], unique=False)
|
||||
op.drop_column('clients', 'model')
|
||||
op.drop_column('clients', 'macs')
|
||||
op.drop_column('clients', 'software_version')
|
||||
op.drop_column('clients', 'os_version')
|
||||
op.drop_column('clients', 'hostname')
|
||||
op.drop_column('clients', 'type')
|
||||
op.drop_column('clients', 'ip')
|
||||
op.drop_column('clients', 'hardware_token')
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,38 @@
|
||||
"""Change uploaded_at to TIMESTAMP in EventMedia
|
||||
|
||||
Revision ID: 216402147826
|
||||
Revises: b22d339ed2af
|
||||
Create Date: 2025-09-01 10:22:55.285710
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '216402147826'
|
||||
down_revision: Union[str, None] = 'b22d339ed2af'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.alter_column('event_media', 'uploaded_at',
|
||||
existing_type=mysql.DATETIME(),
|
||||
type_=sa.TIMESTAMP(),
|
||||
nullable=False)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.alter_column('event_media', 'uploaded_at',
|
||||
existing_type=sa.TIMESTAMP(),
|
||||
type_=mysql.DATETIME(),
|
||||
nullable=True)
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,28 @@
|
||||
"""merge heads after conversions
|
||||
|
||||
Revision ID: 2b627d0885c3
|
||||
Revises: 5b3c1a2f8d10, 8d1df7199cb7
|
||||
Create Date: 2025-10-06 20:27:53.974926
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '2b627d0885c3'
|
||||
down_revision: Union[str, None] = ('5b3c1a2f8d10', '8d1df7199cb7')
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
pass
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
pass
|
||||
@@ -0,0 +1,32 @@
|
||||
"""Add location to client_groups
|
||||
|
||||
Revision ID: 3a09ef909689
|
||||
Revises: 207f5b190f93
|
||||
Create Date: 2025-07-16 08:36:08.535836
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '3a09ef909689'
|
||||
down_revision: Union[str, None] = '207f5b190f93'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('client_groups', sa.Column('location', sa.String(length=100), nullable=True))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('client_groups', 'location')
|
||||
# ### end Alembic commands ###
|
||||
109
server/alembic/versions/3d15c3cac7b6_initial.py
Normal file
109
server/alembic/versions/3d15c3cac7b6_initial.py
Normal file
@@ -0,0 +1,109 @@
|
||||
"""initial
|
||||
|
||||
Revision ID: 3d15c3cac7b6
|
||||
Revises:
|
||||
Create Date: 2025-07-15 09:43:16.209294
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '3d15c3cac7b6'
|
||||
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:
|
||||
"""Upgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('client_groups',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column('name', sa.String(length=100), nullable=False),
|
||||
sa.Column('created_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=True),
|
||||
sa.Column('is_active', sa.Boolean(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('name')
|
||||
)
|
||||
op.create_table('event_media',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column('media_type', sa.Enum('pdf', 'ppt', 'pptx', 'odp', 'mp4', 'avi', 'mkv', 'mov', 'wmv', 'flv', 'webm', 'mpg', 'mpeg', 'ogv', 'jpg', 'jpeg', 'png', 'gif', 'bmp', 'tiff', 'svg', 'html', name='mediatype'), nullable=False),
|
||||
sa.Column('url', sa.String(length=255), nullable=False),
|
||||
sa.Column('file_path', sa.String(length=255), nullable=True),
|
||||
sa.Column('message_content', sa.Text(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('users',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column('username', sa.String(length=50), nullable=False),
|
||||
sa.Column('password_hash', sa.String(length=128), nullable=False),
|
||||
sa.Column('role', sa.Enum('user', 'admin', 'superadmin', name='userrole'), nullable=False),
|
||||
sa.Column('is_active', sa.Boolean(), nullable=False),
|
||||
sa.Column('created_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=True),
|
||||
sa.Column('updated_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_users_username'), 'users', ['username'], unique=True)
|
||||
op.create_table('clients',
|
||||
sa.Column('uuid', sa.String(length=36), nullable=False),
|
||||
sa.Column('hardware_hash', sa.String(length=64), nullable=False),
|
||||
sa.Column('location', sa.String(length=100), nullable=True),
|
||||
sa.Column('ip_address', sa.String(length=45), nullable=True),
|
||||
sa.Column('registration_time', sa.TIMESTAMP(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False),
|
||||
sa.Column('last_alive', sa.TIMESTAMP(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False),
|
||||
sa.Column('is_active', sa.Boolean(), nullable=False),
|
||||
sa.Column('group_id', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['group_id'], ['client_groups.id'], ),
|
||||
sa.PrimaryKeyConstraint('uuid')
|
||||
)
|
||||
op.create_index(op.f('ix_clients_hardware_hash'), 'clients', ['hardware_hash'], unique=False)
|
||||
op.create_index(op.f('ix_clients_ip_address'), 'clients', ['ip_address'], unique=False)
|
||||
op.create_table('events',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column('group_id', sa.Integer(), nullable=False),
|
||||
sa.Column('title', sa.String(length=100), nullable=False),
|
||||
sa.Column('description', sa.Text(), nullable=True),
|
||||
sa.Column('start', sa.TIMESTAMP(timezone=True), nullable=False),
|
||||
sa.Column('end', sa.TIMESTAMP(timezone=True), nullable=False),
|
||||
sa.Column('event_type', sa.Enum('presentation', 'website', 'video', 'message', 'other', 'webuntis', name='eventtype'), nullable=False),
|
||||
sa.Column('event_media_id', sa.Integer(), nullable=True),
|
||||
sa.Column('autoplay', sa.Boolean(), nullable=True),
|
||||
sa.Column('loop', sa.Boolean(), nullable=True),
|
||||
sa.Column('volume', sa.Float(), nullable=True),
|
||||
sa.Column('slideshow_interval', sa.Integer(), nullable=True),
|
||||
sa.Column('created_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=True),
|
||||
sa.Column('updated_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=True),
|
||||
sa.Column('created_by', sa.Integer(), nullable=False),
|
||||
sa.Column('updated_by', sa.Integer(), nullable=True),
|
||||
sa.Column('is_active', sa.Boolean(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['created_by'], ['users.id'], ),
|
||||
sa.ForeignKeyConstraint(['event_media_id'], ['event_media.id'], ),
|
||||
sa.ForeignKeyConstraint(['group_id'], ['client_groups.id'], ),
|
||||
sa.ForeignKeyConstraint(['updated_by'], ['users.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_events_end'), 'events', ['end'], unique=False)
|
||||
op.create_index(op.f('ix_events_group_id'), 'events', ['group_id'], unique=False)
|
||||
op.create_index(op.f('ix_events_start'), 'events', ['start'], unique=False)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f('ix_events_start'), table_name='events')
|
||||
op.drop_index(op.f('ix_events_group_id'), table_name='events')
|
||||
op.drop_index(op.f('ix_events_end'), table_name='events')
|
||||
op.drop_table('events')
|
||||
op.drop_index(op.f('ix_clients_ip_address'), table_name='clients')
|
||||
op.drop_index(op.f('ix_clients_hardware_hash'), table_name='clients')
|
||||
op.drop_table('clients')
|
||||
op.drop_index(op.f('ix_users_username'), table_name='users')
|
||||
op.drop_table('users')
|
||||
op.drop_table('event_media')
|
||||
op.drop_table('client_groups')
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,53 @@
|
||||
"""Add conversions table
|
||||
|
||||
Revision ID: 5b3c1a2f8d10
|
||||
Revises: e6eaede720aa
|
||||
Create Date: 2025-10-06 12:00:00.000000
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '5b3c1a2f8d10'
|
||||
down_revision: Union[str, None] = 'e6eaede720aa'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.create_table(
|
||||
'conversions',
|
||||
sa.Column('id', sa.Integer(), primary_key=True, autoincrement=True),
|
||||
sa.Column('source_event_media_id', sa.Integer(), nullable=False),
|
||||
sa.Column('target_format', sa.String(length=10), nullable=False),
|
||||
sa.Column('target_path', sa.String(length=512), nullable=True),
|
||||
sa.Column('status', sa.Enum('pending', 'processing', 'ready', 'failed', name='conversionstatus'),
|
||||
nullable=False, server_default='pending'),
|
||||
sa.Column('file_hash', sa.String(length=64), nullable=True),
|
||||
sa.Column('started_at', sa.TIMESTAMP(timezone=True), nullable=True),
|
||||
sa.Column('completed_at', sa.TIMESTAMP(timezone=True), nullable=True),
|
||||
sa.Column('error_message', sa.Text(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['source_event_media_id'], ['event_media.id'],
|
||||
name='fk_conversions_event_media', ondelete='CASCADE'),
|
||||
)
|
||||
|
||||
op.create_index('ix_conv_source_event_media_id', 'conversions', ['source_event_media_id'])
|
||||
op.create_index('ix_conversions_target_format', 'conversions', ['target_format'])
|
||||
op.create_index('ix_conv_status_target', 'conversions', ['status', 'target_format'])
|
||||
op.create_index('ix_conv_source_target', 'conversions', ['source_event_media_id', 'target_format'])
|
||||
|
||||
op.create_unique_constraint('uq_conv_source_target_hash', 'conversions',
|
||||
['source_event_media_id', 'target_format', 'file_hash'])
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_constraint('uq_conv_source_target_hash', 'conversions', type_='unique')
|
||||
op.drop_index('ix_conv_source_target', table_name='conversions')
|
||||
op.drop_index('ix_conv_status_target', table_name='conversions')
|
||||
op.drop_index('ix_conversions_target_format', table_name='conversions')
|
||||
op.drop_index('ix_conv_source_event_media_id', table_name='conversions')
|
||||
op.drop_table('conversions')
|
||||
@@ -0,0 +1,28 @@
|
||||
"""merge heads after holidays table
|
||||
|
||||
Revision ID: 71ba7ab08d84
|
||||
Revises: 216402147826, 9b7a1f2a4d2b
|
||||
Create Date: 2025-09-18 19:04:12.755422
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '71ba7ab08d84'
|
||||
down_revision: Union[str, None] = ('216402147826', '9b7a1f2a4d2b')
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
pass
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
pass
|
||||
@@ -0,0 +1,62 @@
|
||||
"""add academic periods system
|
||||
|
||||
Revision ID: 8d1df7199cb7
|
||||
Revises: 71ba7ab08d84
|
||||
Create Date: 2025-09-20 11:07:08.059374
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '8d1df7199cb7'
|
||||
down_revision: Union[str, None] = '71ba7ab08d84'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('academic_periods',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column('name', sa.String(length=100), nullable=False),
|
||||
sa.Column('display_name', sa.String(length=50), nullable=True),
|
||||
sa.Column('start_date', sa.Date(), nullable=False),
|
||||
sa.Column('end_date', sa.Date(), nullable=False),
|
||||
sa.Column('period_type', sa.Enum('schuljahr', 'semester', 'trimester', name='academicperiodtype'), nullable=False),
|
||||
sa.Column('is_active', sa.Boolean(), nullable=False),
|
||||
sa.Column('created_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=True),
|
||||
sa.Column('updated_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('name', name='uq_academic_periods_name')
|
||||
)
|
||||
op.create_index('ix_academic_periods_active', 'academic_periods', ['is_active'], unique=False)
|
||||
op.create_index(op.f('ix_academic_periods_end_date'), 'academic_periods', ['end_date'], unique=False)
|
||||
op.create_index(op.f('ix_academic_periods_start_date'), 'academic_periods', ['start_date'], unique=False)
|
||||
op.add_column('event_media', sa.Column('academic_period_id', sa.Integer(), nullable=True))
|
||||
op.create_index(op.f('ix_event_media_academic_period_id'), 'event_media', ['academic_period_id'], unique=False)
|
||||
op.create_foreign_key(None, 'event_media', 'academic_periods', ['academic_period_id'], ['id'])
|
||||
op.add_column('events', sa.Column('academic_period_id', sa.Integer(), nullable=True))
|
||||
op.create_index(op.f('ix_events_academic_period_id'), 'events', ['academic_period_id'], unique=False)
|
||||
op.create_foreign_key(None, 'events', 'academic_periods', ['academic_period_id'], ['id'])
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint(None, 'events', type_='foreignkey')
|
||||
op.drop_index(op.f('ix_events_academic_period_id'), table_name='events')
|
||||
op.drop_column('events', 'academic_period_id')
|
||||
op.drop_constraint(None, 'event_media', type_='foreignkey')
|
||||
op.drop_index(op.f('ix_event_media_academic_period_id'), table_name='event_media')
|
||||
op.drop_column('event_media', 'academic_period_id')
|
||||
op.drop_index(op.f('ix_academic_periods_start_date'), table_name='academic_periods')
|
||||
op.drop_index(op.f('ix_academic_periods_end_date'), table_name='academic_periods')
|
||||
op.drop_index('ix_academic_periods_active', table_name='academic_periods')
|
||||
op.drop_table('academic_periods')
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,47 @@
|
||||
"""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')
|
||||
@@ -0,0 +1,32 @@
|
||||
"""Add uploaded_at to EventMedia
|
||||
|
||||
Revision ID: b22d339ed2af
|
||||
Revises: e6eaede720aa
|
||||
Create Date: 2025-09-01 10:07:46.915640
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'b22d339ed2af'
|
||||
down_revision: Union[str, None] = 'e6eaede720aa'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('event_media', sa.Column('uploaded_at', sa.DateTime(timezone=True), nullable=True))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('event_media', 'uploaded_at')
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,40 @@
|
||||
"""Make conversions.file_hash NOT NULL
|
||||
|
||||
Revision ID: b5a6c3d4e7f8
|
||||
Revises: 2b627d0885c3
|
||||
Create Date: 2025-10-06 21:05:00.000000
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = "b5a6c3d4e7f8"
|
||||
down_revision: Union[str, None] = "2b627d0885c3"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# Ensure no NULLs remain before altering nullability
|
||||
op.execute("UPDATE conversions SET file_hash = '' WHERE file_hash IS NULL")
|
||||
op.alter_column(
|
||||
"conversions",
|
||||
"file_hash",
|
||||
existing_type=sa.String(length=64),
|
||||
nullable=False,
|
||||
existing_nullable=True,
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.alter_column(
|
||||
"conversions",
|
||||
"file_hash",
|
||||
existing_type=sa.String(length=64),
|
||||
nullable=True,
|
||||
existing_nullable=False,
|
||||
)
|
||||
@@ -0,0 +1,34 @@
|
||||
"""Add website to MediaType enum
|
||||
|
||||
Revision ID: e6eaede720aa
|
||||
Revises: 0c47280d3e2d
|
||||
Create Date: 2025-07-24 13:40:50.553863
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'e6eaede720aa'
|
||||
down_revision: Union[str, None] = '0c47280d3e2d'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.execute(
|
||||
"ALTER TABLE event_media MODIFY COLUMN media_type ENUM('pdf','ppt','pptx','odp','mp4','avi','mkv','mov','wmv','flv','webm','mpg','mpeg','ogv','jpg','jpeg','png','gif','bmp','tiff','svg','html','website') NOT NULL;"
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user