"""generate rules

Revision ID: 2e94ae517de8
Revises: 7b6db971e3a4
Create Date: 2025-08-10 09:37:34.879433

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '2e94ae517de8'
down_revision = '7b6db971e3a4'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('ai_rule_cache',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('folder_name', sa.String(length=255), nullable=False),
    sa.Column('folder_type', sa.String(length=20), nullable=False),
    sa.Column('rule_text', sa.Text(), nullable=False),
    sa.Column('rule_metadata', sa.JSON(), nullable=True),
    sa.Column('cache_key', sa.String(length=64), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('expires_at', sa.DateTime(), nullable=False),
    sa.Column('is_active', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('cache_key')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('ai_rule_cache')
    # ### end Alembic commands ###
