diff --git a/lemur/migrations/versions/368320d26c6c_.py b/lemur/migrations/versions/29d8c8455c86_.py similarity index 54% rename from lemur/migrations/versions/368320d26c6c_.py rename to lemur/migrations/versions/29d8c8455c86_.py index 7c31f43f..f0b4749f 100644 --- a/lemur/migrations/versions/368320d26c6c_.py +++ b/lemur/migrations/versions/29d8c8455c86_.py @@ -1,22 +1,39 @@ -"""empty message +"""Adding endpoint tables -Revision ID: 368320d26c6c +Revision ID: 29d8c8455c86 Revises: 3307381f3b88 -Create Date: 2016-05-27 13:41:47.413694 +Create Date: 2016-06-28 16:05:25.720213 """ # revision identifiers, used by Alembic. -revision = '368320d26c6c' +revision = '29d8c8455c86' down_revision = '3307381f3b88' from alembic import op import sqlalchemy as sa -import sqlalchemy_utils +from sqlalchemy.dialects import postgresql def upgrade(): ### commands auto generated by Alembic - please adjust! ### + op.create_table('ciphers', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('name', sa.String(length=128), nullable=False), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('policy', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('name', sa.String(length=128), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('policies_ciphers', + sa.Column('cipher_id', sa.Integer(), nullable=True), + sa.Column('policy_id', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['cipher_id'], ['ciphers.id'], ), + sa.ForeignKeyConstraint(['policy_id'], ['policy.id'], ) + ) + op.create_index('policies_ciphers_ix', 'policies_ciphers', ['cipher_id', 'policy_id'], unique=False) op.create_table('endpoints', sa.Column('id', sa.Integer(), nullable=False), sa.Column('owner', sa.String(length=128), nullable=True), @@ -26,16 +43,10 @@ def upgrade(): sa.Column('active', sa.Boolean(), nullable=True), sa.Column('port', sa.Integer(), nullable=True), sa.Column('date_created', sa.DateTime(), server_default=sa.text(u'now()'), nullable=False), + sa.Column('policy_id', sa.Integer(), nullable=True), sa.Column('certificate_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['certificate_id'], ['certificates.id'], ), - sa.PrimaryKeyConstraint('id') - ) - op.create_table('policy', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('endpoint_id', sa.Integer(), nullable=True), - sa.Column('name', sa.String(length=32), nullable=True), - sa.Column('ciphers', sqlalchemy_utils.types.json.JSONType(), nullable=True), - sa.ForeignKeyConstraint(['endpoint_id'], ['endpoints.id'], ), + sa.ForeignKeyConstraint(['policy_id'], ['policy.id'], ), sa.PrimaryKeyConstraint('id') ) ### end Alembic commands ### @@ -43,6 +54,9 @@ def upgrade(): def downgrade(): ### commands auto generated by Alembic - please adjust! ### - op.drop_table('policy') op.drop_table('endpoints') + op.drop_index('policies_ciphers_ix', table_name='policies_ciphers') + op.drop_table('policies_ciphers') + op.drop_table('policy') + op.drop_table('ciphers') ### end Alembic commands ###