Adding endpoint migration script. (#376)
This commit is contained in:
parent
c8447dea3d
commit
ecbab64c35
|
@ -1,22 +1,39 @@
|
||||||
"""empty message
|
"""Adding endpoint tables
|
||||||
|
|
||||||
Revision ID: 368320d26c6c
|
Revision ID: 29d8c8455c86
|
||||||
Revises: 3307381f3b88
|
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 identifiers, used by Alembic.
|
||||||
revision = '368320d26c6c'
|
revision = '29d8c8455c86'
|
||||||
down_revision = '3307381f3b88'
|
down_revision = '3307381f3b88'
|
||||||
|
|
||||||
from alembic import op
|
from alembic import op
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
import sqlalchemy_utils
|
from sqlalchemy.dialects import postgresql
|
||||||
|
|
||||||
|
|
||||||
def upgrade():
|
def upgrade():
|
||||||
### commands auto generated by Alembic - please adjust! ###
|
### 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',
|
op.create_table('endpoints',
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
sa.Column('owner', sa.String(length=128), nullable=True),
|
sa.Column('owner', sa.String(length=128), nullable=True),
|
||||||
|
@ -26,16 +43,10 @@ def upgrade():
|
||||||
sa.Column('active', sa.Boolean(), nullable=True),
|
sa.Column('active', sa.Boolean(), nullable=True),
|
||||||
sa.Column('port', sa.Integer(), 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('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.Column('certificate_id', sa.Integer(), nullable=True),
|
||||||
sa.ForeignKeyConstraint(['certificate_id'], ['certificates.id'], ),
|
sa.ForeignKeyConstraint(['certificate_id'], ['certificates.id'], ),
|
||||||
sa.PrimaryKeyConstraint('id')
|
sa.ForeignKeyConstraint(['policy_id'], ['policy.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.PrimaryKeyConstraint('id')
|
sa.PrimaryKeyConstraint('id')
|
||||||
)
|
)
|
||||||
### end Alembic commands ###
|
### end Alembic commands ###
|
||||||
|
@ -43,6 +54,9 @@ def upgrade():
|
||||||
|
|
||||||
def downgrade():
|
def downgrade():
|
||||||
### commands auto generated by Alembic - please adjust! ###
|
### commands auto generated by Alembic - please adjust! ###
|
||||||
op.drop_table('policy')
|
|
||||||
op.drop_table('endpoints')
|
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 ###
|
### end Alembic commands ###
|
Loading…
Reference in New Issue