Changed project name to be IPTV Manager Service
All checks were successful
AWS Deploy on Push / build (push) Successful in 8m29s
All checks were successful
AWS Deploy on Push / build (push) Successful in 8m29s
This commit is contained in:
79
alembic/versions/95b61a92455a_create_initial_tables.py
Normal file
79
alembic/versions/95b61a92455a_create_initial_tables.py
Normal file
@@ -0,0 +1,79 @@
|
||||
"""create initial tables
|
||||
|
||||
Revision ID: 95b61a92455a
|
||||
Revises:
|
||||
Create Date: 2025-05-29 14:42:16.239587
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '95b61a92455a'
|
||||
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('channels',
|
||||
sa.Column('id', sa.UUID(), nullable=False),
|
||||
sa.Column('tvg_id', sa.String(), nullable=False),
|
||||
sa.Column('name', sa.String(), nullable=False),
|
||||
sa.Column('group_title', sa.String(), nullable=False),
|
||||
sa.Column('tvg_name', sa.String(), nullable=True),
|
||||
sa.Column('tvg_logo', sa.String(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('group_title', 'name', name='uix_group_title_name')
|
||||
)
|
||||
op.create_table('priorities',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('description', sa.String(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('channels_urls',
|
||||
sa.Column('id', sa.UUID(), nullable=False),
|
||||
sa.Column('channel_id', sa.UUID(), nullable=False),
|
||||
sa.Column('url', sa.String(), nullable=False),
|
||||
sa.Column('in_use', sa.Boolean(), nullable=False),
|
||||
sa.Column('priority_id', sa.Integer(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['channel_id'], ['channels.id'], ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['priority_id'], ['priorities.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
# Seed initial priorities
|
||||
op.bulk_insert(
|
||||
sa.Table(
|
||||
'priorities',
|
||||
sa.MetaData(),
|
||||
sa.Column('id', sa.Integer),
|
||||
sa.Column('description', sa.String),
|
||||
),
|
||||
[
|
||||
{'id': 100, 'description': 'High'},
|
||||
{'id': 200, 'description': 'Medium'},
|
||||
{'id': 300, 'description': 'Low'},
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# Remove seeded priorities
|
||||
op.execute("DELETE FROM priorities WHERE id IN (100, 200, 300);")
|
||||
|
||||
# Drop tables
|
||||
op.drop_table('channels_urls')
|
||||
op.drop_table('priorities')
|
||||
op.drop_table('channels')
|
||||
Reference in New Issue
Block a user