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:
@@ -15,7 +15,8 @@ config = context.config
|
||||
if config.config_file_name is not None:
|
||||
fileConfig(config.config_file_name)
|
||||
|
||||
# Setup target metadata for autogenerate support
|
||||
# add your model's MetaData object here
|
||||
# for 'autogenerate' support
|
||||
target_metadata = Base.metadata
|
||||
|
||||
# Override sqlalchemy.url with dynamic credentials
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
"""Add priority and in_use fields
|
||||
|
||||
Revision ID: 036879e47172
|
||||
Revises:
|
||||
Create Date: 2025-05-26 19:21:32.285656
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '036879e47172'
|
||||
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! ###
|
||||
# 1. Create priorities table if not exists
|
||||
if not op.get_bind().engine.dialect.has_table(op.get_bind(), 'priorities'):
|
||||
op.create_table('priorities',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('description', sa.String(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
|
||||
# 2. Insert default priorities (skip if already exists)
|
||||
op.execute("""
|
||||
INSERT INTO priorities (id, description)
|
||||
VALUES (100, 'High'), (200, 'Medium'), (300, 'Low')
|
||||
ON CONFLICT (id) DO NOTHING
|
||||
""")
|
||||
# Add new columns with temporary nullable=True
|
||||
op.add_column('channels_urls', sa.Column('in_use', sa.Boolean(), nullable=True))
|
||||
op.add_column('channels_urls', sa.Column('priority_id', sa.Integer(), nullable=True))
|
||||
|
||||
# Set default values
|
||||
op.execute("UPDATE channels_urls SET in_use = false, priority_id = 100")
|
||||
|
||||
# Convert to NOT NULL
|
||||
op.alter_column('channels_urls', 'in_use', nullable=False)
|
||||
op.alter_column('channels_urls', 'priority_id', nullable=False)
|
||||
op.create_foreign_key(None, 'channels_urls', 'priorities', ['priority_id'], ['id'])
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint('channels_urls_priority_id_fkey', 'channels_urls', type_='foreignkey')
|
||||
op.drop_column('channels_urls', 'priority_id')
|
||||
op.drop_column('channels_urls', 'in_use')
|
||||
op.drop_table('priorities')
|
||||
# ### end Alembic commands ###
|
||||
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