"""add fields an samples_fields

Revision ID: d74ea5a68cbb
Revises: dd97a1d782ad
Create Date: 2022-08-12 15:31:00.728476

"""
from alembic import op
import sqlalchemy as sa


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


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('fields',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_fields_name'), 'fields', ['name'], unique=False)
    op.create_table('samples_fields',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('sample_id', sa.Integer(), nullable=True),
    sa.Column('field_id', sa.Integer(), nullable=True),
    sa.Column('original_name', sa.String(), nullable=True),
    sa.Column('value', sa.String(), nullable=True),
    sa.Column('data_source_url', sa.String(), nullable=True),
    sa.Column('data_source_notes', sa.Text(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.ForeignKeyConstraint(['field_id'], ['fields.id'], ),
    sa.ForeignKeyConstraint(['sample_id'], ['samples.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_samples_fields_data_source_notes'), 'samples_fields', ['data_source_notes'], unique=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_samples_fields_data_source_notes'), table_name='samples_fields')
    op.drop_table('samples_fields')
    op.drop_index(op.f('ix_fields_name'), table_name='fields')
    op.drop_table('fields')
    # ### end Alembic commands ###
