homelab_automation/alembic/versions/0020_add_is_pinned_to_terminal.py
Bruno Charest d29eefcef4
Some checks failed
Tests / Backend Tests (Python) (3.10) (push) Has been cancelled
Tests / Backend Tests (Python) (3.11) (push) Has been cancelled
Tests / Backend Tests (Python) (3.12) (push) Has been cancelled
Tests / Frontend Tests (JS) (push) Has been cancelled
Tests / Integration Tests (push) Has been cancelled
Tests / All Tests Passed (push) Has been cancelled
feat: Implement web-based terminal with session management, command history, and dedicated UI.
2026-03-03 11:51:57 -05:00

43 lines
1.3 KiB
Python

"""add is_pinned to terminal command logs
Revision ID: 0020
Revises: 0019_add_container_customizations
Create Date: 2026-03-03 10:00:00.000000
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
from sqlalchemy import inspect
# revision identifiers, used by Alembic.
revision: str = '0020'
down_revision: Union[str, None] = '0019_add_container_customizations'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# Check if column already exists to avoid errors
bind = op.get_bind()
insp = inspect(bind)
columns = [col['name'] for col in insp.get_columns('terminal_command_logs')]
if 'is_pinned' not in columns:
# Add is_pinned column with default 0
op.add_column('terminal_command_logs', sa.Column('is_pinned', sa.Boolean(), server_default=sa.text('0'), nullable=False))
def downgrade() -> None:
# Check if column exists before dropping
bind = op.get_bind()
insp = inspect(bind)
columns = [col['name'] for col in insp.get_columns('terminal_command_logs')]
if 'is_pinned' in columns:
# Drop column
with op.batch_alter_table('terminal_command_logs') as batch_op:
batch_op.drop_column('is_pinned')