<filename>db_migrations/versions/927d5ceb3e86_init.py
"""init

Revision ID: 927d5ceb3e86
Create Date: 2017-02-17 11:39:34.769993

"""

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

from alembic import op
import sqlalchemy as sa


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('participant',
    sa.Column('id', sa.INTEGER(), autoincrement=False, nullable=False),
    sa.Column('gender', sa.Enum('M', 'F', 'O', name='gender'), nullable=True),
    sa.Column('birth_date', sa.DATE(), nullable=True),
    sa.Column('age', sa.DECIMAL(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('participant_mapping',
    sa.Column('name', sa.VARCHAR(length=50), nullable=False),
    sa.Column('dataset', sa.VARCHAR(length=50), nullable=False),
    sa.Column('participant_id', sa.INTEGER(), nullable=True),
    sa.PrimaryKeyConstraint('name', 'dataset'),
    sa.UniqueConstraint('participant_id')
    )
    op.create_table('provenance',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('dataset', sa.VARCHAR(length=50), nullable=False),
    sa.Column('matlab_version', sa.VARCHAR(length=50), nullable=True),
    sa.Column('spm_version', sa.VARCHAR(length=50), nullable=True),
    sa.Column('spm_revision', sa.VARCHAR(length=50), nullable=True),
    sa.Column('fn_called', sa.VARCHAR(length=50), nullable=True),
    sa.Column('fn_version', sa.VARCHAR(length=50), nullable=True),
    sa.Column('others', sa.TEXT(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('dataset', 'matlab_version', 'spm_version', 'spm_revision', 'fn_called', 'fn_version', 'others')
    )
    op.create_table('sequence_type',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('name', sa.VARCHAR(length=200), nullable=False),
    sa.Column('manufacturer', sa.VARCHAR(length=200), nullable=True),
    sa.Column('manufacturer_model_name', sa.VARCHAR(length=200), nullable=True),
    sa.Column('institution_name', sa.VARCHAR(length=200), nullable=True),
    sa.Column('slice_thickness', sa.DECIMAL(), nullable=True),
    sa.Column('repetition_time', sa.DECIMAL(), nullable=True),
    sa.Column('echo_time', sa.DECIMAL(), nullable=True),
    sa.Column('echo_number', sa.INTEGER(), nullable=True),
    sa.Column('number_of_phase_encoding_steps', sa.INTEGER(), nullable=True),
    sa.Column('percent_phase_field_of_view', sa.DECIMAL(), nullable=True),
    sa.Column('pixel_bandwidth', sa.INTEGER(), nullable=True),
    sa.Column('flip_angle', sa.DECIMAL(), nullable=True),
    sa.Column('rows', sa.INTEGER(), nullable=True),
    sa.Column('columns', sa.INTEGER(), nullable=True),
    sa.Column('magnetic_field_strength', sa.DECIMAL(), nullable=True),
    sa.Column('space_between_slices', sa.DECIMAL(), nullable=True),
    sa.Column('echo_train_length', sa.INTEGER(), nullable=True),
    sa.Column('percent_sampling', sa.DECIMAL(), nullable=True),
    sa.Column('pixel_spacing_0', sa.DECIMAL(), nullable=True),
    sa.Column('pixel_spacing_1', sa.DECIMAL(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('visit_mapping',
    sa.Column('name', sa.VARCHAR(length=50), nullable=False),
    sa.Column('dataset', sa.VARCHAR(length=50), nullable=False),
    sa.Column('visit_id', sa.INTEGER(), nullable=True),
    sa.PrimaryKeyConstraint('name', 'dataset'),
    sa.UniqueConstraint('visit_id')
    )
    op.create_table('processing_step',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('name', sa.VARCHAR(length=200), nullable=False),
    sa.Column('provenance_id', sa.INTEGER(), nullable=False),
    sa.Column('previous_step_id', sa.INTEGER(), nullable=True),
    sa.Column('execution_date', sa.DATE(), nullable=True),
    sa.ForeignKeyConstraint(['previous_step_id'], ['processing_step.id'], ),
    sa.ForeignKeyConstraint(['provenance_id'], ['provenance.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name', 'provenance_id')
    )
    op.create_table('visit',
    sa.Column('id', sa.INTEGER(), autoincrement=False, nullable=False),
    sa.Column('date', sa.DATE(), nullable=True),
    sa.Column('role', sa.Enum('C', 'P', 'IC', name='participant_role'), nullable=True),
    sa.Column('comment', sa.TEXT(), nullable=True),
    sa.Column('participant_id', sa.INTEGER(), nullable=False),
    sa.ForeignKeyConstraint(['participant_id'], ['participant.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('session',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('name', sa.VARCHAR(length=50), nullable=False),
    sa.Column('visit_id', sa.INTEGER(), nullable=False),
    sa.Column('date', sa.DATE(), nullable=True),
    sa.ForeignKeyConstraint(['visit_id'], ['visit.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name', 'visit_id')
    )
    op.create_table('sequence',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('name', sa.VARCHAR(length=50), nullable=False),
    sa.Column('session_id', sa.INTEGER(), nullable=False),
    sa.Column('sequence_type_id', sa.INTEGER(), nullable=True),
    sa.ForeignKeyConstraint(['sequence_type_id'], ['sequence_type.id'], ),
    sa.ForeignKeyConstraint(['session_id'], ['session.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name', 'session_id')
    )
    op.create_table('repetition',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('name', sa.VARCHAR(length=50), nullable=False),
    sa.Column('sequence_id', sa.INTEGER(), nullable=False),
    sa.Column('date', sa.DATE(), nullable=True),
    sa.ForeignKeyConstraint(['sequence_id'], ['sequence.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name', 'sequence_id')
    )
    op.create_table('data_file',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('path', sa.TEXT(), nullable=False),
    sa.Column('type', sa.VARCHAR(length=50), nullable=False),
    sa.Column('processing_step_id', sa.INTEGER(), nullable=False),
    sa.Column('repetition_id', sa.INTEGER(), nullable=True),
    sa.Column('is_copy', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['processing_step_id'], ['processing_step.id'], ),
    sa.ForeignKeyConstraint(['repetition_id'], ['repetition.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('path')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('data_file')
    op.drop_table('repetition')
    op.drop_table('sequence')
    op.drop_table('session')
    op.drop_table('visit')
    op.drop_table('processing_step')
    op.drop_table('visit_mapping')
    op.drop_table('sequence_type')
    op.drop_table('provenance')
    op.drop_table('participant_mapping')
    op.drop_table('participant')
    # ### end Alembic commands ###

<filename>db_migrations/versions/927d5ceb3e86_init.py
"""init

Revision ID: 927d5ceb3e86
Create Date: 2017-02-17 11:39:34.769993

"""

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

from alembic import op
import sqlalchemy as sa


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('participant',
    sa.Column('id', sa.INTEGER(), autoincrement=False, nullable=False),
    sa.Column('gender', sa.Enum('M', 'F', 'O', name='gender'), nullable=True),
    sa.Column('birth_date', sa.DATE(), nullable=True),
    sa.Column('age', sa.DECIMAL(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('participant_mapping',
    sa.Column('name', sa.VARCHAR(length=50), nullable=False),
    sa.Column('dataset', sa.VARCHAR(length=50), nullable=False),
    sa.Column('participant_id', sa.INTEGER(), nullable=True),
    sa.PrimaryKeyConstraint('name', 'dataset'),
    sa.UniqueConstraint('participant_id')
    )
    op.create_table('provenance',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('dataset', sa.VARCHAR(length=50), nullable=False),
    sa.Column('matlab_version', sa.VARCHAR(length=50), nullable=True),
    sa.Column('spm_version', sa.VARCHAR(length=50), nullable=True),
    sa.Column('spm_revision', sa.VARCHAR(length=50), nullable=True),
    sa.Column('fn_called', sa.VARCHAR(length=50), nullable=True),
    sa.Column('fn_version', sa.VARCHAR(length=50), nullable=True),
    sa.Column('others', sa.TEXT(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('dataset', 'matlab_version', 'spm_version', 'spm_revision', 'fn_called', 'fn_version', 'others')
    )
    op.create_table('sequence_type',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('name', sa.VARCHAR(length=200), nullable=False),
    sa.Column('manufacturer', sa.VARCHAR(length=200), nullable=True),
    sa.Column('manufacturer_model_name', sa.VARCHAR(length=200), nullable=True),
    sa.Column('institution_name', sa.VARCHAR(length=200), nullable=True),
    sa.Column('slice_thickness', sa.DECIMAL(), nullable=True),
    sa.Column('repetition_time', sa.DECIMAL(), nullable=True),
    sa.Column('echo_time', sa.DECIMAL(), nullable=True),
    sa.Column('echo_number', sa.INTEGER(), nullable=True),
    sa.Column('number_of_phase_encoding_steps', sa.INTEGER(), nullable=True),
    sa.Column('percent_phase_field_of_view', sa.DECIMAL(), nullable=True),
    sa.Column('pixel_bandwidth', sa.INTEGER(), nullable=True),
    sa.Column('flip_angle', sa.DECIMAL(), nullable=True),
    sa.Column('rows', sa.INTEGER(), nullable=True),
    sa.Column('columns', sa.INTEGER(), nullable=True),
    sa.Column('magnetic_field_strength', sa.DECIMAL(), nullable=True),
    sa.Column('space_between_slices', sa.DECIMAL(), nullable=True),
    sa.Column('echo_train_length', sa.INTEGER(), nullable=True),
    sa.Column('percent_sampling', sa.DECIMAL(), nullable=True),
    sa.Column('pixel_spacing_0', sa.DECIMAL(), nullable=True),
    sa.Column('pixel_spacing_1', sa.DECIMAL(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('visit_mapping',
    sa.Column('name', sa.VARCHAR(length=50), nullable=False),
    sa.Column('dataset', sa.VARCHAR(length=50), nullable=False),
    sa.Column('visit_id', sa.INTEGER(), nullable=True),
    sa.PrimaryKeyConstraint('name', 'dataset'),
    sa.UniqueConstraint('visit_id')
    )
    op.create_table('processing_step',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('name', sa.VARCHAR(length=200), nullable=False),
    sa.Column('provenance_id', sa.INTEGER(), nullable=False),
    sa.Column('previous_step_id', sa.INTEGER(), nullable=True),
    sa.Column('execution_date', sa.DATE(), nullable=True),
    sa.ForeignKeyConstraint(['previous_step_id'], ['processing_step.id'], ),
    sa.ForeignKeyConstraint(['provenance_id'], ['provenance.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name', 'provenance_id')
    )
    op.create_table('visit',
    sa.Column('id', sa.INTEGER(), autoincrement=False, nullable=False),
    sa.Column('date', sa.DATE(), nullable=True),
    sa.Column('role', sa.Enum('C', 'P', 'IC', name='participant_role'), nullable=True),
    sa.Column('comment', sa.TEXT(), nullable=True),
    sa.Column('participant_id', sa.INTEGER(), nullable=False),
    sa.ForeignKeyConstraint(['participant_id'], ['participant.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('session',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('name', sa.VARCHAR(length=50), nullable=False),
    sa.Column('visit_id', sa.INTEGER(), nullable=False),
    sa.Column('date', sa.DATE(), nullable=True),
    sa.ForeignKeyConstraint(['visit_id'], ['visit.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name', 'visit_id')
    )
    op.create_table('sequence',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('name', sa.VARCHAR(length=50), nullable=False),
    sa.Column('session_id', sa.INTEGER(), nullable=False),
    sa.Column('sequence_type_id', sa.INTEGER(), nullable=True),
    sa.ForeignKeyConstraint(['sequence_type_id'], ['sequence_type.id'], ),
    sa.ForeignKeyConstraint(['session_id'], ['session.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name', 'session_id')
    )
    op.create_table('repetition',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('name', sa.VARCHAR(length=50), nullable=False),
    sa.Column('sequence_id', sa.INTEGER(), nullable=False),
    sa.Column('date', sa.DATE(), nullable=True),
    sa.ForeignKeyConstraint(['sequence_id'], ['sequence.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name', 'sequence_id')
    )
    op.create_table('data_file',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('path', sa.TEXT(), nullable=False),
    sa.Column('type', sa.VARCHAR(length=50), nullable=False),
    sa.Column('processing_step_id', sa.INTEGER(), nullable=False),
    sa.Column('repetition_id', sa.INTEGER(), nullable=True),
    sa.Column('is_copy', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['processing_step_id'], ['processing_step.id'], ),
    sa.ForeignKeyConstraint(['repetition_id'], ['repetition.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('path')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('data_file')
    op.drop_table('repetition')
    op.drop_table('sequence')
    op.drop_table('session')
    op.drop_table('visit')
    op.drop_table('processing_step')
    op.drop_table('visit_mapping')
    op.drop_table('sequence_type')
    op.drop_table('provenance')
    op.drop_table('participant_mapping')
    op.drop_table('participant')
    # ### end Alembic commands ###

init  Revision ID: 927d5ceb3e86 Create Date: 2017-02-17 11:39:34.769993 # revision identifiers, used by Alembic. # ### commands auto generated by Alembic - please adjust! ### # ### end Alembic commands ### # ### commands auto generated by Alembic - please adjust! ### # ### end Alembic commands ###