|
| 1 | +"""adds_refinery_playground_evaluation |
| 2 | +
|
| 3 | +Revision ID: ac97442726d2 |
| 4 | +Revises: eb5ecbee5090 |
| 5 | +Create Date: 2025-01-16 13:26:43.059523 |
| 6 | +
|
| 7 | +""" |
| 8 | +from alembic import op |
| 9 | +import sqlalchemy as sa |
| 10 | +from sqlalchemy.dialects import postgresql |
| 11 | + |
| 12 | +# revision identifiers, used by Alembic. |
| 13 | +revision = 'ac97442726d2' |
| 14 | +down_revision = 'eb5ecbee5090' |
| 15 | +branch_labels = None |
| 16 | +depends_on = None |
| 17 | + |
| 18 | + |
| 19 | +def upgrade(): |
| 20 | + # ### commands auto generated by Alembic - please adjust! ### |
| 21 | + op.create_table('evaluation_group', |
| 22 | + sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), |
| 23 | + sa.Column('name', sa.String(), nullable=True), |
| 24 | + sa.Column('created_at', sa.DateTime(), nullable=True), |
| 25 | + sa.Column('created_by', postgresql.UUID(as_uuid=True), nullable=True), |
| 26 | + sa.Column('project_id', postgresql.UUID(as_uuid=True), nullable=True), |
| 27 | + sa.Column('evaluation_set_ids', sa.JSON(), nullable=True), |
| 28 | + sa.ForeignKeyConstraint(['created_by'], ['user.id'], ondelete='SET NULL'), |
| 29 | + sa.ForeignKeyConstraint(['project_id'], ['project.id'], ondelete='CASCADE'), |
| 30 | + sa.PrimaryKeyConstraint('id') |
| 31 | + ) |
| 32 | + op.create_index(op.f('ix_evaluation_group_created_by'), 'evaluation_group', ['created_by'], unique=False) |
| 33 | + op.create_index(op.f('ix_evaluation_group_project_id'), 'evaluation_group', ['project_id'], unique=False) |
| 34 | + op.create_table('evaluation_set', |
| 35 | + sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), |
| 36 | + sa.Column('question', sa.String(), nullable=True), |
| 37 | + sa.Column('created_at', sa.DateTime(), nullable=True), |
| 38 | + sa.Column('created_by', postgresql.UUID(as_uuid=True), nullable=True), |
| 39 | + sa.Column('project_id', postgresql.UUID(as_uuid=True), nullable=True), |
| 40 | + sa.Column('record_ids', sa.JSON(), nullable=True), |
| 41 | + sa.ForeignKeyConstraint(['created_by'], ['user.id'], ondelete='SET NULL'), |
| 42 | + sa.ForeignKeyConstraint(['project_id'], ['project.id'], ondelete='CASCADE'), |
| 43 | + sa.PrimaryKeyConstraint('id') |
| 44 | + ) |
| 45 | + op.create_index(op.f('ix_evaluation_set_created_by'), 'evaluation_set', ['created_by'], unique=False) |
| 46 | + op.create_index(op.f('ix_evaluation_set_project_id'), 'evaluation_set', ['project_id'], unique=False) |
| 47 | + op.create_table('evaluation_run', |
| 48 | + sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), |
| 49 | + sa.Column('evaluation_group_id', postgresql.UUID(as_uuid=True), nullable=True), |
| 50 | + sa.Column('created_at', sa.DateTime(), nullable=True), |
| 51 | + sa.Column('created_by', postgresql.UUID(as_uuid=True), nullable=True), |
| 52 | + sa.Column('project_id', postgresql.UUID(as_uuid=True), nullable=True), |
| 53 | + sa.Column('embedding_id', postgresql.UUID(as_uuid=True), nullable=True), |
| 54 | + sa.Column('state', sa.String(), nullable=True), |
| 55 | + sa.Column('results', sa.JSON(), nullable=True), |
| 56 | + sa.Column('meta_info', sa.JSON(), nullable=True), |
| 57 | + sa.ForeignKeyConstraint(['created_by'], ['user.id'], ondelete='SET NULL'), |
| 58 | + sa.ForeignKeyConstraint(['embedding_id'], ['embedding.id'], ondelete='SET NULL'), |
| 59 | + sa.ForeignKeyConstraint(['evaluation_group_id'], ['evaluation_group.id'], ondelete='SET NULL'), |
| 60 | + sa.ForeignKeyConstraint(['project_id'], ['project.id'], ondelete='CASCADE'), |
| 61 | + sa.PrimaryKeyConstraint('id') |
| 62 | + ) |
| 63 | + op.create_index(op.f('ix_evaluation_run_created_by'), 'evaluation_run', ['created_by'], unique=False) |
| 64 | + op.create_index(op.f('ix_evaluation_run_embedding_id'), 'evaluation_run', ['embedding_id'], unique=False) |
| 65 | + op.create_index(op.f('ix_evaluation_run_evaluation_group_id'), 'evaluation_run', ['evaluation_group_id'], unique=False) |
| 66 | + op.create_index(op.f('ix_evaluation_run_project_id'), 'evaluation_run', ['project_id'], unique=False) |
| 67 | + # ### end Alembic commands ### |
| 68 | + |
| 69 | + |
| 70 | +def downgrade(): |
| 71 | + # ### commands auto generated by Alembic - please adjust! ### |
| 72 | + op.drop_index(op.f('ix_evaluation_run_project_id'), table_name='evaluation_run') |
| 73 | + op.drop_index(op.f('ix_evaluation_run_evaluation_group_id'), table_name='evaluation_run') |
| 74 | + op.drop_index(op.f('ix_evaluation_run_embedding_id'), table_name='evaluation_run') |
| 75 | + op.drop_index(op.f('ix_evaluation_run_created_by'), table_name='evaluation_run') |
| 76 | + op.drop_table('evaluation_run') |
| 77 | + op.drop_index(op.f('ix_evaluation_set_project_id'), table_name='evaluation_set') |
| 78 | + op.drop_index(op.f('ix_evaluation_set_created_by'), table_name='evaluation_set') |
| 79 | + op.drop_table('evaluation_set') |
| 80 | + op.drop_index(op.f('ix_evaluation_group_project_id'), table_name='evaluation_group') |
| 81 | + op.drop_index(op.f('ix_evaluation_group_created_by'), table_name='evaluation_group') |
| 82 | + op.drop_table('evaluation_group') |
| 83 | + # ### end Alembic commands ### |
0 commit comments