From a12bfa7623b996c2eed45d239c2987b693ce1729 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Thu, 5 Feb 2015 15:30:45 -0500 Subject: [PATCH] Add migration for the new tables for signatures --- .../5ad999136045_add_signature_storage.py | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 data/migrations/versions/5ad999136045_add_signature_storage.py diff --git a/data/migrations/versions/5ad999136045_add_signature_storage.py b/data/migrations/versions/5ad999136045_add_signature_storage.py new file mode 100644 index 000000000..6f5c36695 --- /dev/null +++ b/data/migrations/versions/5ad999136045_add_signature_storage.py @@ -0,0 +1,50 @@ +"""Add signature storage + +Revision ID: 5ad999136045 +Revises: 228d1af6af1c +Create Date: 2015-02-05 15:01:54.989573 + +""" + +# revision identifiers, used by Alembic. +revision = '5ad999136045' +down_revision = '228d1af6af1c' + +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import mysql + +def upgrade(tables): + ### commands auto generated by Alembic - please adjust! ### + op.create_table('imagestoragesignaturekind', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('name', sa.String(length=255), nullable=False), + sa.PrimaryKeyConstraint('id', name=op.f('pk_imagestoragesignaturekind')) + ) + op.create_index('imagestoragesignaturekind_name', 'imagestoragesignaturekind', ['name'], unique=True) + op.create_table('imagestoragesignature', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('storage_id', sa.Integer(), nullable=False), + sa.Column('kind_id', sa.Integer(), nullable=False), + sa.Column('signature', sa.Text(), nullable=True), + sa.Column('uploading', sa.Boolean(), nullable=True), + sa.ForeignKeyConstraint(['kind_id'], ['imagestoragesignaturekind.id'], name=op.f('fk_imagestoragesignature_kind_id_imagestoragesignaturekind')), + sa.ForeignKeyConstraint(['storage_id'], ['imagestorage.id'], name=op.f('fk_imagestoragesignature_storage_id_imagestorage')), + sa.PrimaryKeyConstraint('id', name=op.f('pk_imagestoragesignature')) + ) + op.create_index('imagestoragesignature_kind_id', 'imagestoragesignature', ['kind_id'], unique=False) + op.create_index('imagestoragesignature_kind_id_storage_id', 'imagestoragesignature', ['kind_id', 'storage_id'], unique=True) + op.create_index('imagestoragesignature_storage_id', 'imagestoragesignature', ['storage_id'], unique=False) + ### end Alembic commands ### + + op.bulk_insert(tables.imagestoragesignaturekind, + [ + {'id': 1, 'name':'gpg2'}, + ]) + + +def downgrade(tables): + ### commands auto generated by Alembic - please adjust! ### + op.drop_table('imagestoragesignature') + op.drop_table('imagestoragesignaturekind') + ### end Alembic commands ###