From a0cbdd53580252ca30272c1df82d58fb10885c45 Mon Sep 17 00:00:00 2001 From: "Choi A.K." Date: Fri, 5 Sep 2025 15:03:13 +0900 Subject: [PATCH] migrations and db creation --- alembic/versions/eeb6744b9452_init.py | 59 ++++++++++++--------------- 1 file changed, 25 insertions(+), 34 deletions(-) diff --git a/alembic/versions/eeb6744b9452_init.py b/alembic/versions/eeb6744b9452_init.py index df25abd..75f2d6b 100644 --- a/alembic/versions/eeb6744b9452_init.py +++ b/alembic/versions/eeb6744b9452_init.py @@ -19,48 +19,39 @@ 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( + 'admins', + sa.Column('id', sa.Integer(), primary_key=True), + sa.Column('tg_id', sa.Integer(), unique=True, nullable=False), ) - 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( + 'channels', + sa.Column('id', sa.Integer(), primary_key=True), + sa.Column('name', sa.String, nullable=True), + sa.Column('link', sa.String, nullable=True), + sa.Column('admin_id', sa.Integer(), sa.ForeignKey('admins.id'), nullable=True), ) - 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( + 'groups', + sa.Column('id', sa.Integer(), primary_key=True), + sa.Column('name', sa.String, nullable=False), + sa.Column('link', sa.String, nullable=False), + sa.Column('admin_id', sa.Integer(), sa.ForeignKey('admins.id'), nullable=True), ) - 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') + op.create_table( + 'buttons', + sa.Column('id', sa.Integer(), primary_key=True), + sa.Column('name', sa.String, nullable=False), + sa.Column('url', sa.String, nullable=False), + sa.Column('channel_id', sa.Integer(), sa.ForeignKey('channels.id'), nullable=True), + sa.Column('group_id', sa.Integer(), sa.ForeignKey('groups.id'), nullable=True), ) - # ### 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 ###