mirror of
https://github.com/koloideal/DutyLog.git
synced 2026-06-10 18:35:29 +03:00
48 lines
1.7 KiB
Python
48 lines
1.7 KiB
Python
"""add models
|
|
|
|
Revision ID: c7a225e7de2f
|
|
Revises: 8861cafdae4f
|
|
Create Date: 2026-03-03 22:13:33.354768
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = 'c7a225e7de2f'
|
|
down_revision: Union[str, Sequence[str], None] = '8861cafdae4f'
|
|
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('room_hours_transactions',
|
|
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
|
sa.Column('room_id', sa.Integer(), nullable=False),
|
|
sa.Column('transaction_type', sa.String(length=50), nullable=False),
|
|
sa.Column('amount', sa.Integer(), nullable=False),
|
|
sa.Column('admin_id', sa.BigInteger(), nullable=True),
|
|
sa.Column('remark', sa.String(length=500), nullable=True),
|
|
sa.Column('created_at', sa.DateTime(timezone=True), nullable=False),
|
|
sa.ForeignKeyConstraint(['admin_id'], ['users.id'], ondelete='SET NULL'),
|
|
sa.ForeignKeyConstraint(['room_id'], ['rooms.id'], ondelete='CASCADE'),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.add_column('rooms', sa.Column('active_hours', sa.Integer(), server_default='0', nullable=False))
|
|
op.add_column('rooms', sa.Column('inactive_hours', sa.Integer(), server_default='0', nullable=False))
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
"""Downgrade schema."""
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_column('rooms', 'inactive_hours')
|
|
op.drop_column('rooms', 'active_hours')
|
|
op.drop_table('room_hours_transactions')
|
|
# ### end Alembic commands ###
|