Refactor database schema and update event media
handling
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
"""Refactor EventMedia: move playback fields to events, add MediaType enum, remove order
|
||||
|
||||
Revision ID: bb29b5524f5c
|
||||
Revises: fadba5bc526c
|
||||
Create Date: 2025-07-05 05:13:31.837339
|
||||
|
||||
"""
|
||||
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 = 'bb29b5524f5c'
|
||||
down_revision: Union[str, None] = 'fadba5bc526c'
|
||||
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.drop_column('event_media', 'autoplay')
|
||||
op.drop_column('event_media', 'order')
|
||||
op.drop_column('event_media', 'loop')
|
||||
op.drop_column('event_media', 'volume')
|
||||
op.add_column('events', sa.Column('autoplay', sa.Boolean(), nullable=True))
|
||||
op.add_column('events', sa.Column('loop', sa.Boolean(), nullable=True))
|
||||
op.add_column('events', sa.Column('volume', sa.Float(), nullable=True))
|
||||
op.add_column('events', sa.Column('slideshow_interval', sa.Integer(), nullable=True))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('events', 'slideshow_interval')
|
||||
op.drop_column('events', 'volume')
|
||||
op.drop_column('events', 'loop')
|
||||
op.drop_column('events', 'autoplay')
|
||||
op.add_column('event_media', sa.Column('volume', mysql.FLOAT(), nullable=True))
|
||||
op.add_column('event_media', sa.Column('loop', mysql.TINYINT(display_width=1), autoincrement=False, nullable=True))
|
||||
op.add_column('event_media', sa.Column('order', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True))
|
||||
op.add_column('event_media', sa.Column('autoplay', mysql.TINYINT(display_width=1), autoincrement=False, nullable=True))
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,46 @@
|
||||
"""Refactor Event/EventMedia relation
|
||||
|
||||
Revision ID: c571e4214528
|
||||
Revises: d490cbfdea65
|
||||
Create Date: 2025-07-04 06:08:57.004474
|
||||
|
||||
"""
|
||||
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 = 'c571e4214528'
|
||||
down_revision: Union[str, None] = 'd490cbfdea65'
|
||||
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_foreign_key(None, 'clients', 'client_groups', ['group_id'], ['id'])
|
||||
op.drop_constraint(op.f('event_media_ibfk_1'), 'event_media', type_='foreignkey')
|
||||
op.drop_column('event_media', 'event_id')
|
||||
op.add_column('events', sa.Column('event_media_id', sa.Integer(), nullable=True))
|
||||
op.alter_column('events', 'group_id',
|
||||
existing_type=mysql.INTEGER(display_width=11),
|
||||
nullable=False)
|
||||
op.create_foreign_key(None, 'events', 'event_media', ['event_media_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.alter_column('events', 'group_id',
|
||||
existing_type=mysql.INTEGER(display_width=11),
|
||||
nullable=True)
|
||||
op.drop_column('events', 'event_media_id')
|
||||
op.add_column('event_media', sa.Column('event_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=False))
|
||||
op.create_foreign_key(op.f('event_media_ibfk_1'), 'event_media', 'events', ['event_id'], ['id'])
|
||||
op.drop_constraint(None, 'clients', type_='foreignkey')
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,34 @@
|
||||
"""Add Filepath and Message-Content to EventMedia
|
||||
|
||||
Revision ID: fadba5bc526c
|
||||
Revises: c571e4214528
|
||||
Create Date: 2025-07-05 04:46:13.542887
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'fadba5bc526c'
|
||||
down_revision: Union[str, None] = 'c571e4214528'
|
||||
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('file_path', sa.String(length=255), nullable=True))
|
||||
op.add_column('event_media', sa.Column('message_content', sa.Text(), nullable=True))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('event_media', 'message_content')
|
||||
op.drop_column('event_media', 'file_path')
|
||||
# ### end Alembic commands ###
|
||||
@@ -59,6 +59,35 @@ class EventType(enum.Enum):
|
||||
webuntis = "webuntis"
|
||||
|
||||
|
||||
class MediaType(enum.Enum):
|
||||
# Präsentationen
|
||||
pdf = "pdf"
|
||||
ppt = "ppt"
|
||||
pptx = "pptx"
|
||||
odp = "odp"
|
||||
# Videos (gängige VLC-Formate)
|
||||
mp4 = "mp4"
|
||||
avi = "avi"
|
||||
mkv = "mkv"
|
||||
mov = "mov"
|
||||
wmv = "wmv"
|
||||
flv = "flv"
|
||||
webm = "webm"
|
||||
mpg = "mpg"
|
||||
mpeg = "mpeg"
|
||||
ogv = "ogv"
|
||||
# Bilder (benutzerfreundlich)
|
||||
jpg = "jpg"
|
||||
jpeg = "jpeg"
|
||||
png = "png"
|
||||
gif = "gif"
|
||||
bmp = "bmp"
|
||||
tiff = "tiff"
|
||||
svg = "svg"
|
||||
# HTML-Mitteilung
|
||||
html = "html"
|
||||
|
||||
|
||||
class Event(Base):
|
||||
__tablename__ = 'events'
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
@@ -69,6 +98,12 @@ class Event(Base):
|
||||
start = Column(TIMESTAMP(timezone=True), nullable=False, index=True)
|
||||
end = Column(TIMESTAMP(timezone=True), nullable=False, index=True)
|
||||
event_type = Column(Enum(EventType), nullable=False)
|
||||
event_media_id = Column(Integer, ForeignKey(
|
||||
'event_media.id'), nullable=True)
|
||||
autoplay = Column(Boolean, nullable=True) # NEU
|
||||
loop = Column(Boolean, nullable=True) # NEU
|
||||
volume = Column(Float, nullable=True) # NEU
|
||||
slideshow_interval = Column(Integer, nullable=True) # NEU
|
||||
created_at = Column(TIMESTAMP(timezone=True),
|
||||
server_default=func.current_timestamp())
|
||||
updated_at = Column(TIMESTAMP(timezone=True), server_default=func.current_timestamp(
|
||||
@@ -81,12 +116,7 @@ class Event(Base):
|
||||
class EventMedia(Base):
|
||||
__tablename__ = 'event_media'
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
event_id = Column(Integer, ForeignKey('events.id'), nullable=False)
|
||||
media_type = Column(Enum(EventType), nullable=False)
|
||||
media_type = Column(Enum(MediaType), nullable=False) # Enum angepasst!
|
||||
url = Column(String(255), nullable=False)
|
||||
order = Column(Integer, nullable=True)
|
||||
autoplay = Column(Boolean, nullable=True)
|
||||
loop = Column(Boolean, nullable=True)
|
||||
volume = Column(Float, nullable=True)
|
||||
|
||||
# Indizes für Performance (werden bei index=True automatisch gesetzt)
|
||||
file_path = Column(String(255), nullable=True)
|
||||
message_content = Column(Text, nullable=True)
|
||||
|
||||
Reference in New Issue
Block a user