"""add instances table

Revision ID: add_instances_table
Revises: 
Create Date: 2024-03-19 10:00:00.000000

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'add_instances_table'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    op.create_table('instances',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('name', sa.String(length=100), nullable=False),
        sa.Column('company', sa.String(length=100), nullable=False),
        sa.Column('rooms_count', sa.Integer(), nullable=False, server_default='0'),
        sa.Column('conversations_count', sa.Integer(), nullable=False, server_default='0'),
        sa.Column('data_size', sa.Float(), nullable=False, server_default='0.0'),
        sa.Column('payment_plan', sa.String(length=20), nullable=False, server_default='Basic'),
        sa.Column('main_url', sa.String(length=255), nullable=False),
        sa.Column('status', sa.String(length=20), nullable=False, server_default='inactive'),
        sa.Column('created_at', sa.DateTime(), nullable=False, server_default=sa.text('CURRENT_TIMESTAMP')),
        sa.Column('updated_at', sa.DateTime(), nullable=False, server_default=sa.text('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP')),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('name'),
        sa.UniqueConstraint('main_url')
    )


def downgrade():
    op.drop_table('instances') 