Files
DevOpsLab/app/alembic/versions/008_add_roles_table.py
Сергей Антропов 1fbf9185a2 feat: добавлена пометка типа операции (Build/Push) в истории сборок Dockerfile
- Добавлена колонка 'Тип' во все таблицы истории сборок
- Для push операций отображается registry вместо платформ
- Сохранение пользователя при создании push лога
- Исправлена ошибка с logger в push_docker_image endpoint
- Улучшено отображение истории сборок с визуальными индикаторами
2026-02-15 22:59:02 +03:00

59 lines
2.6 KiB
Python

"""Add roles table
Revision ID: 008
Revises: 007
Create Date: 2024-01-06 12:00:00.000000
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = '008'
down_revision = '007'
branch_labels = None
depends_on = None
def upgrade() -> None:
"""Создание таблицы roles для хранения Ansible ролей"""
op.create_table(
'roles',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(), nullable=False),
sa.Column('description', sa.Text(), nullable=True),
sa.Column('content', postgresql.JSON(astext_type=sa.Text()), nullable=False),
sa.Column('is_global', sa.Boolean(), nullable=False, server_default='false'),
sa.Column('is_personal', sa.Boolean(), nullable=False, server_default='false'),
sa.Column('groups', postgresql.JSON(astext_type=sa.Text()), nullable=True),
sa.Column('user_id', sa.Integer(), nullable=True),
sa.Column('author', sa.String(), nullable=True),
sa.Column('platforms', postgresql.JSON(astext_type=sa.Text()), nullable=True),
sa.Column('galaxy_info', postgresql.JSON(astext_type=sa.Text()), nullable=True),
sa.Column('status', sa.String(), server_default='active', nullable=True),
sa.Column('created_at', sa.DateTime(), nullable=False),
sa.Column('updated_at', sa.DateTime(), nullable=False),
sa.Column('created_by', sa.String(), nullable=True),
sa.Column('updated_by', sa.String(), nullable=True),
sa.Column('extra_data', postgresql.JSON(astext_type=sa.Text()), nullable=True),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('name')
)
op.create_index(op.f('ix_roles_name'), 'roles', ['name'], unique=True)
op.create_index(op.f('ix_roles_is_global'), 'roles', ['is_global'], unique=False)
op.create_index(op.f('ix_roles_is_personal'), 'roles', ['is_personal'], unique=False)
op.create_index(op.f('ix_roles_user_id'), 'roles', ['user_id'], unique=False)
op.create_index(op.f('ix_roles_created_at'), 'roles', ['created_at'], unique=False)
def downgrade() -> None:
"""Удаление таблицы roles"""
op.drop_index(op.f('ix_roles_created_at'), table_name='roles')
op.drop_index(op.f('ix_roles_user_id'), table_name='roles')
op.drop_index(op.f('ix_roles_is_personal'), table_name='roles')
op.drop_index(op.f('ix_roles_is_global'), table_name='roles')
op.drop_index(op.f('ix_roles_name'), table_name='roles')
op.drop_table('roles')