This commit is contained in:
@@ -1,32 +0,0 @@
|
||||
"""init
|
||||
|
||||
Revision ID: 69ef23ef1ed1
|
||||
Revises:
|
||||
Create Date: 2025-09-05 13:53:02.737876
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '69ef23ef1ed1'
|
||||
down_revision: Union[str, Sequence[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! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
@@ -1,39 +0,0 @@
|
||||
"""channel table
|
||||
|
||||
Revision ID: 7506a3320699
|
||||
Revises: 69ef23ef1ed1
|
||||
Create Date: 2025-09-05 14:12:37.430983
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.sql import table, column
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '7506a3320699'
|
||||
down_revision: Union[str, Sequence[str], None] = '69ef23ef1ed1'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
# Для SQLite: добавляем столбцы через ALTER TABLE
|
||||
conn = op.get_bind()
|
||||
# Добавить столбец link, если его нет
|
||||
result = conn.execute(sa.text("PRAGMA table_info(channels)")).fetchall()
|
||||
columns = [row[1] for row in result]
|
||||
if 'link' not in columns:
|
||||
conn.execute(sa.text("ALTER TABLE channels ADD COLUMN link VARCHAR(255)"))
|
||||
# Добавить столбец admin_id, если его нет
|
||||
if 'admin_id' not in columns:
|
||||
conn.execute(sa.text("ALTER TABLE channels ADD COLUMN admin_id INTEGER"))
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# SQLite не поддерживает удаление столбцов, поэтому просто удаляем таблицу
|
||||
op.drop_table('channels')
|
||||
66
alembic/versions/eeb6744b9452_init.py
Normal file
66
alembic/versions/eeb6744b9452_init.py
Normal file
@@ -0,0 +1,66 @@
|
||||
"""init
|
||||
|
||||
Revision ID: eeb6744b9452
|
||||
Revises:
|
||||
Create Date: 2025-09-05 14:55:12.005564
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'eeb6744b9452'
|
||||
down_revision: Union[str, Sequence[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('admins',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('tg_id', sa.Integer(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('tg_id')
|
||||
)
|
||||
op.create_table('channels',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('name', sa.String(), nullable=True),
|
||||
sa.Column('link', sa.String(), nullable=True),
|
||||
sa.Column('admin_id', sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['admin_id'], ['admins.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('groups',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('name', sa.String(), nullable=False),
|
||||
sa.Column('link', sa.String(), nullable=False),
|
||||
sa.Column('admin_id', sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['admin_id'], ['admins.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('buttons',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('name', sa.String(), nullable=False),
|
||||
sa.Column('url', sa.String(), nullable=False),
|
||||
sa.Column('channel_id', sa.Integer(), nullable=True),
|
||||
sa.Column('group_id', sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['channel_id'], ['channels.id'], ),
|
||||
sa.ForeignKeyConstraint(['group_id'], ['groups.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('buttons')
|
||||
op.drop_table('groups')
|
||||
op.drop_table('channels')
|
||||
op.drop_table('admins')
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user