"""Color schema Revision ID: 96687673c2bd Revises: 05eb90fee9bf Create Date: 2019-05-16 13:31:20.104564 """ from alembic import op import sqlalchemy as sa from migrations import utils # revision identifiers, used by Alembic. revision = '96687673c2bd' down_revision = '05eb90fee9bf' branch_labels = None depends_on = None def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table( 'ColorSchema', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(), nullable=False), sa.Column('schema', sa.JSON(), nullable=False), sa.PrimaryKeyConstraint('id', name=op.f('pk_ColorSchema')) ) bind = op.get_bind() session = sa.orm.Session(bind=bind) # fill color schemas color_schemas = [ { 'id': 1, 'name': 'Pink', 'schema': { 'circleBackground': '#FF3377', 'circleBorder': '#FF3377', 'mainBackground': '#FFE6EF', 'mainLeftBorder': '#FE4583', 'mainText': '#F22469', 'mainThreeDots': '#FE4583' } }, { 'id': 2, 'name': 'Purple', 'schema': { 'circleBackground': '#F4E3FC', 'circleBorder': '#A641D9', 'mainBackground': '#F7E6FF', 'mainLeftBorder': '#A641D9', 'mainText': '#9529CC', 'mainThreeDots': '#A641D9' } }, { 'id': 3, 'name': 'Blue', 'schema': { 'circleBackground': '#E3EEFC', 'circleBorder': '#2B74D9', 'mainBackground': '#E6F1FF', 'mainLeftBorder': '#2B74D9', 'mainText': '#1461CC', 'mainThreeDots': '#2B74D9' } }, { 'id': 4, 'name': 'Green', 'schema': { 'circleBackground': '#DFF7ED', 'circleBorder': '#00B369', 'mainBackground': '#DFF7ED', 'mainLeftBorder': '#00B369', 'mainText': '#00804B', 'mainThreeDots': '#00B369' } }, { 'id': 5, 'name': 'Yellow', 'schema': { 'circleBackground': '#FAF6E1', 'circleBorder': '#D4A700', 'mainBackground': '#FCF8E3', 'mainLeftBorder': '#D4A700', 'mainText': '#806A00', 'mainThreeDots': '#D4A700' } }, { 'id': 6, 'name': 'Orange', 'schema': { 'circleBackground': '#FCECE3', 'circleBorder': '#F27130', 'mainBackground': '#FFEFE6', 'mainLeftBorder': '#F27130', 'mainText': '#E65C17', 'mainThreeDots': '#F27130' } }, ] utils.import_data_json("ColorSchema", color_schemas) session.commit() session.close() op.add_column( 'Campaign', sa.Column( 'color_schema_id', sa.Integer(), server_default=sa.text('3'), nullable=False ) ) op.create_foreign_key( op.f('fk_Campaign_color_schema_id_ColorSchema'), 'Campaign', 'ColorSchema', ['color_schema_id'], ['id'] ) # ### end Alembic commands ### def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.drop_constraint( op.f('fk_Campaign_color_schema_id_ColorSchema'), 'Campaign', type_='foreignkey' ) op.drop_column('Campaign', 'color_schema_id') op.drop_table('ColorSchema') # ### end Alembic commands ###