feat: добавлена пометка типа операции (Build/Push) в истории сборок Dockerfile
- Добавлена колонка 'Тип' во все таблицы истории сборок - Для push операций отображается registry вместо платформ - Сохранение пользователя при создании push лога - Исправлена ошибка с logger в push_docker_image endpoint - Улучшено отображение истории сборок с визуальными индикаторами
This commit is contained in:
53
app/alembic/versions/001_initial_migration.py
Normal file
53
app/alembic/versions/001_initial_migration.py
Normal file
@@ -0,0 +1,53 @@
|
||||
"""Initial migration with users table
|
||||
|
||||
Revision ID: 001_initial
|
||||
Revises:
|
||||
Create Date: 2024-01-01 00:00:00.000000
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '001_initial'
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# Создание таблицы users
|
||||
op.create_table(
|
||||
'users',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('username', sa.String(), nullable=False),
|
||||
sa.Column('hashed_password', sa.String(), nullable=False),
|
||||
sa.Column('is_active', sa.Boolean(), nullable=False, server_default='true'),
|
||||
sa.Column('is_superuser', sa.Boolean(), nullable=False, server_default='false'),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False, server_default=sa.text('now()')),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=False, server_default=sa.text('now()')),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_users_id'), 'users', ['id'], unique=False)
|
||||
op.create_index(op.f('ix_users_username'), 'users', ['username'], unique=True)
|
||||
|
||||
# Создание пользователя admin/admin по умолчанию
|
||||
# Пароль будет хеширован при первом входе через UserService
|
||||
# Используем простой временный хеш, который будет обновлен при первом входе
|
||||
import bcrypt
|
||||
temp_hash = bcrypt.hashpw(b'admin', bcrypt.gensalt()).decode('utf-8')
|
||||
|
||||
# Используем параметризованный запрос
|
||||
op.execute(
|
||||
sa.text("""
|
||||
INSERT INTO users (username, hashed_password, is_active, is_superuser)
|
||||
VALUES ('admin', :hash, true, true)
|
||||
ON CONFLICT (username) DO NOTHING;
|
||||
""").bindparams(hash=temp_hash)
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_index(op.f('ix_users_username'), table_name='users')
|
||||
op.drop_index(op.f('ix_users_id'), table_name='users')
|
||||
op.drop_table('users')
|
||||
Reference in New Issue
Block a user