Black lint all the things
This commit is contained in:
@ -19,8 +19,11 @@ fileConfig(config.config_file_name)
|
||||
# from myapp import mymodel
|
||||
# target_metadata = mymodel.Base.metadata
|
||||
from flask import current_app
|
||||
config.set_main_option('sqlalchemy.url', current_app.config.get('SQLALCHEMY_DATABASE_URI'))
|
||||
target_metadata = current_app.extensions['migrate'].db.metadata
|
||||
|
||||
config.set_main_option(
|
||||
"sqlalchemy.url", current_app.config.get("SQLALCHEMY_DATABASE_URI")
|
||||
)
|
||||
target_metadata = current_app.extensions["migrate"].db.metadata
|
||||
|
||||
# other values from the config, defined by the needs of env.py,
|
||||
# can be acquired:
|
||||
@ -54,14 +57,18 @@ def run_migrations_online():
|
||||
and associate a connection with the context.
|
||||
|
||||
"""
|
||||
engine = engine_from_config(config.get_section(config.config_ini_section),
|
||||
prefix='sqlalchemy.',
|
||||
poolclass=pool.NullPool)
|
||||
engine = engine_from_config(
|
||||
config.get_section(config.config_ini_section),
|
||||
prefix="sqlalchemy.",
|
||||
poolclass=pool.NullPool,
|
||||
)
|
||||
|
||||
connection = engine.connect()
|
||||
context.configure(connection=connection,
|
||||
target_metadata=target_metadata,
|
||||
**current_app.extensions['migrate'].configure_args)
|
||||
context.configure(
|
||||
connection=connection,
|
||||
target_metadata=target_metadata,
|
||||
**current_app.extensions["migrate"].configure_args
|
||||
)
|
||||
|
||||
try:
|
||||
with context.begin_transaction():
|
||||
@ -69,8 +76,8 @@ def run_migrations_online():
|
||||
finally:
|
||||
connection.close()
|
||||
|
||||
|
||||
if context.is_offline_mode():
|
||||
run_migrations_offline()
|
||||
else:
|
||||
run_migrations_online()
|
||||
|
||||
|
@ -7,8 +7,8 @@ Create Date: 2016-12-07 17:29:42.049986
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '131ec6accff5'
|
||||
down_revision = 'e3691fc396e9'
|
||||
revision = "131ec6accff5"
|
||||
down_revision = "e3691fc396e9"
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
@ -16,13 +16,24 @@ import sqlalchemy as sa
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('certificates', sa.Column('rotation', sa.Boolean(), nullable=False, server_default=sa.false()))
|
||||
op.add_column('endpoints', sa.Column('last_updated', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
|
||||
op.add_column(
|
||||
"certificates",
|
||||
sa.Column("rotation", sa.Boolean(), nullable=False, server_default=sa.false()),
|
||||
)
|
||||
op.add_column(
|
||||
"endpoints",
|
||||
sa.Column(
|
||||
"last_updated",
|
||||
sa.DateTime(),
|
||||
server_default=sa.text("now()"),
|
||||
nullable=False,
|
||||
),
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('endpoints', 'last_updated')
|
||||
op.drop_column('certificates', 'rotation')
|
||||
op.drop_column("endpoints", "last_updated")
|
||||
op.drop_column("certificates", "rotation")
|
||||
# ### end Alembic commands ###
|
||||
|
@ -7,15 +7,19 @@ Create Date: 2017-07-13 12:32:09.162800
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '1ae8e3104db8'
|
||||
down_revision = 'a02a678ddc25'
|
||||
revision = "1ae8e3104db8"
|
||||
down_revision = "a02a678ddc25"
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.sync_enum_values('public', 'log_type', ['key_view'], ['create_cert', 'key_view', 'update_cert'])
|
||||
op.sync_enum_values(
|
||||
"public", "log_type", ["key_view"], ["create_cert", "key_view", "update_cert"]
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.sync_enum_values('public', 'log_type', ['create_cert', 'key_view', 'update_cert'], ['key_view'])
|
||||
op.sync_enum_values(
|
||||
"public", "log_type", ["create_cert", "key_view", "update_cert"], ["key_view"]
|
||||
)
|
||||
|
@ -7,8 +7,8 @@ Create Date: 2018-08-03 12:56:44.565230
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '1db4f82bc780'
|
||||
down_revision = '3adfdd6598df'
|
||||
revision = "1db4f82bc780"
|
||||
down_revision = "3adfdd6598df"
|
||||
|
||||
import logging
|
||||
|
||||
@ -20,12 +20,14 @@ log = logging.getLogger(__name__)
|
||||
def upgrade():
|
||||
connection = op.get_bind()
|
||||
|
||||
result = connection.execute("""\
|
||||
result = connection.execute(
|
||||
"""\
|
||||
UPDATE certificates
|
||||
SET rotation_policy_id=(SELECT id FROM rotation_policies WHERE name='default')
|
||||
WHERE rotation_policy_id IS NULL
|
||||
RETURNING id
|
||||
""")
|
||||
"""
|
||||
)
|
||||
log.info("Filled rotation_policy for %d certificates" % result.rowcount)
|
||||
|
||||
|
||||
|
@ -7,8 +7,8 @@ Create Date: 2016-06-28 16:05:25.720213
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '29d8c8455c86'
|
||||
down_revision = '3307381f3b88'
|
||||
revision = "29d8c8455c86"
|
||||
down_revision = "3307381f3b88"
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
@ -17,46 +17,60 @@ 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(
|
||||
"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(
|
||||
"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_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),
|
||||
sa.Column('name', sa.String(length=128), nullable=True),
|
||||
sa.Column('dnsname', sa.String(length=256), nullable=True),
|
||||
sa.Column('type', sa.String(length=128), nullable=True),
|
||||
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.ForeignKeyConstraint(['policy_id'], ['policy.id'], ),
|
||||
sa.PrimaryKeyConstraint('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),
|
||||
sa.Column("name", sa.String(length=128), nullable=True),
|
||||
sa.Column("dnsname", sa.String(length=256), nullable=True),
|
||||
sa.Column("type", sa.String(length=128), nullable=True),
|
||||
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.ForeignKeyConstraint(["policy_id"], ["policy.id"]),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
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')
|
||||
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 ###
|
||||
|
@ -7,8 +7,8 @@ Create Date: 2019-02-05 15:42:25.477587
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '318b66568358'
|
||||
down_revision = '9f79024fe67b'
|
||||
revision = "318b66568358"
|
||||
down_revision = "9f79024fe67b"
|
||||
|
||||
from alembic import op
|
||||
|
||||
@ -16,7 +16,7 @@ from alembic import op
|
||||
def upgrade():
|
||||
connection = op.get_bind()
|
||||
# Delete duplicate entries
|
||||
connection.execute('UPDATE certificates SET deleted = false WHERE deleted IS NULL')
|
||||
connection.execute("UPDATE certificates SET deleted = false WHERE deleted IS NULL")
|
||||
|
||||
|
||||
def downgrade():
|
||||
|
@ -12,8 +12,8 @@ Create Date: 2016-05-20 17:33:04.360687
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '3307381f3b88'
|
||||
down_revision = '412b22cb656a'
|
||||
revision = "3307381f3b88"
|
||||
down_revision = "412b22cb656a"
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
@ -23,109 +23,165 @@ from sqlalchemy.dialects import postgresql
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.alter_column('authorities', 'owner',
|
||||
existing_type=sa.VARCHAR(length=128),
|
||||
nullable=True)
|
||||
op.drop_column('authorities', 'not_after')
|
||||
op.drop_column('authorities', 'bits')
|
||||
op.drop_column('authorities', 'cn')
|
||||
op.drop_column('authorities', 'not_before')
|
||||
op.add_column('certificates', sa.Column('root_authority_id', sa.Integer(), nullable=True))
|
||||
op.alter_column('certificates', 'body',
|
||||
existing_type=sa.TEXT(),
|
||||
nullable=False)
|
||||
op.alter_column('certificates', 'owner',
|
||||
existing_type=sa.VARCHAR(length=128),
|
||||
nullable=True)
|
||||
op.drop_constraint(u'certificates_authority_id_fkey', 'certificates', type_='foreignkey')
|
||||
op.create_foreign_key(None, 'certificates', 'authorities', ['authority_id'], ['id'], ondelete='CASCADE')
|
||||
op.create_foreign_key(None, 'certificates', 'authorities', ['root_authority_id'], ['id'], ondelete='CASCADE')
|
||||
op.alter_column(
|
||||
"authorities", "owner", existing_type=sa.VARCHAR(length=128), nullable=True
|
||||
)
|
||||
op.drop_column("authorities", "not_after")
|
||||
op.drop_column("authorities", "bits")
|
||||
op.drop_column("authorities", "cn")
|
||||
op.drop_column("authorities", "not_before")
|
||||
op.add_column(
|
||||
"certificates", sa.Column("root_authority_id", sa.Integer(), nullable=True)
|
||||
)
|
||||
op.alter_column("certificates", "body", existing_type=sa.TEXT(), nullable=False)
|
||||
op.alter_column(
|
||||
"certificates", "owner", existing_type=sa.VARCHAR(length=128), nullable=True
|
||||
)
|
||||
op.drop_constraint(
|
||||
u"certificates_authority_id_fkey", "certificates", type_="foreignkey"
|
||||
)
|
||||
op.create_foreign_key(
|
||||
None,
|
||||
"certificates",
|
||||
"authorities",
|
||||
["authority_id"],
|
||||
["id"],
|
||||
ondelete="CASCADE",
|
||||
)
|
||||
op.create_foreign_key(
|
||||
None,
|
||||
"certificates",
|
||||
"authorities",
|
||||
["root_authority_id"],
|
||||
["id"],
|
||||
ondelete="CASCADE",
|
||||
)
|
||||
### end Alembic commands ###
|
||||
|
||||
# link existing certificate to their authority certificates
|
||||
conn = op.get_bind()
|
||||
for id, body, owner in conn.execute(text('select id, body, owner from authorities')):
|
||||
for id, body, owner in conn.execute(
|
||||
text("select id, body, owner from authorities")
|
||||
):
|
||||
if not owner:
|
||||
owner = "lemur@nobody"
|
||||
|
||||
# look up certificate by body, if duplications are found, pick one
|
||||
stmt = text('select id from certificates where body=:body')
|
||||
stmt = text("select id from certificates where body=:body")
|
||||
stmt = stmt.bindparams(body=body)
|
||||
root_certificate = conn.execute(stmt).fetchone()
|
||||
if root_certificate:
|
||||
stmt = text('update certificates set root_authority_id=:root_authority_id where id=:id')
|
||||
stmt = text(
|
||||
"update certificates set root_authority_id=:root_authority_id where id=:id"
|
||||
)
|
||||
stmt = stmt.bindparams(root_authority_id=id, id=root_certificate[0])
|
||||
op.execute(stmt)
|
||||
|
||||
# link owner roles to their authorities
|
||||
stmt = text('select id from roles where name=:name')
|
||||
stmt = text("select id from roles where name=:name")
|
||||
stmt = stmt.bindparams(name=owner)
|
||||
owner_role = conn.execute(stmt).fetchone()
|
||||
|
||||
if not owner_role:
|
||||
stmt = text('insert into roles (name, description) values (:name, :description)')
|
||||
stmt = stmt.bindparams(name=owner, description='Lemur generated role or existing owner.')
|
||||
stmt = text(
|
||||
"insert into roles (name, description) values (:name, :description)"
|
||||
)
|
||||
stmt = stmt.bindparams(
|
||||
name=owner, description="Lemur generated role or existing owner."
|
||||
)
|
||||
op.execute(stmt)
|
||||
|
||||
stmt = text('select id from roles where name=:name')
|
||||
stmt = text("select id from roles where name=:name")
|
||||
stmt = stmt.bindparams(name=owner)
|
||||
owner_role = conn.execute(stmt).fetchone()
|
||||
|
||||
stmt = text('select * from roles_authorities where role_id=:role_id and authority_id=:authority_id')
|
||||
stmt = text(
|
||||
"select * from roles_authorities where role_id=:role_id and authority_id=:authority_id"
|
||||
)
|
||||
stmt = stmt.bindparams(role_id=owner_role[0], authority_id=id)
|
||||
exists = conn.execute(stmt).fetchone()
|
||||
|
||||
if not exists:
|
||||
stmt = text('insert into roles_authorities (role_id, authority_id) values (:role_id, :authority_id)')
|
||||
stmt = text(
|
||||
"insert into roles_authorities (role_id, authority_id) values (:role_id, :authority_id)"
|
||||
)
|
||||
stmt = stmt.bindparams(role_id=owner_role[0], authority_id=id)
|
||||
op.execute(stmt)
|
||||
|
||||
# link owner roles to their certificates
|
||||
for id, owner in conn.execute(text('select id, owner from certificates')):
|
||||
for id, owner in conn.execute(text("select id, owner from certificates")):
|
||||
if not owner:
|
||||
owner = "lemur@nobody"
|
||||
|
||||
stmt = text('select id from roles where name=:name')
|
||||
stmt = text("select id from roles where name=:name")
|
||||
stmt = stmt.bindparams(name=owner)
|
||||
owner_role = conn.execute(stmt).fetchone()
|
||||
|
||||
if not owner_role:
|
||||
stmt = text('insert into roles (name, description) values (:name, :description)')
|
||||
stmt = stmt.bindparams(name=owner, description='Lemur generated role or existing owner.')
|
||||
stmt = text(
|
||||
"insert into roles (name, description) values (:name, :description)"
|
||||
)
|
||||
stmt = stmt.bindparams(
|
||||
name=owner, description="Lemur generated role or existing owner."
|
||||
)
|
||||
op.execute(stmt)
|
||||
|
||||
# link owner roles to their authorities
|
||||
stmt = text('select id from roles where name=:name')
|
||||
stmt = text("select id from roles where name=:name")
|
||||
stmt = stmt.bindparams(name=owner)
|
||||
owner_role = conn.execute(stmt).fetchone()
|
||||
|
||||
stmt = text('select * from roles_certificates where role_id=:role_id and certificate_id=:certificate_id')
|
||||
stmt = text(
|
||||
"select * from roles_certificates where role_id=:role_id and certificate_id=:certificate_id"
|
||||
)
|
||||
stmt = stmt.bindparams(role_id=owner_role[0], certificate_id=id)
|
||||
exists = conn.execute(stmt).fetchone()
|
||||
|
||||
if not exists:
|
||||
stmt = text('insert into roles_certificates (role_id, certificate_id) values (:role_id, :certificate_id)')
|
||||
stmt = text(
|
||||
"insert into roles_certificates (role_id, certificate_id) values (:role_id, :certificate_id)"
|
||||
)
|
||||
stmt = stmt.bindparams(role_id=owner_role[0], certificate_id=id)
|
||||
op.execute(stmt)
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint(None, 'certificates', type_='foreignkey')
|
||||
op.drop_constraint(None, 'certificates', type_='foreignkey')
|
||||
op.create_foreign_key(u'certificates_authority_id_fkey', 'certificates', 'authorities', ['authority_id'], ['id'])
|
||||
op.alter_column('certificates', 'owner',
|
||||
existing_type=sa.VARCHAR(length=128),
|
||||
nullable=True)
|
||||
op.alter_column('certificates', 'body',
|
||||
existing_type=sa.TEXT(),
|
||||
nullable=True)
|
||||
op.drop_column('certificates', 'root_authority_id')
|
||||
op.add_column('authorities', sa.Column('not_before', postgresql.TIMESTAMP(), autoincrement=False, nullable=True))
|
||||
op.add_column('authorities', sa.Column('cn', sa.VARCHAR(length=128), autoincrement=False, nullable=True))
|
||||
op.add_column('authorities', sa.Column('bits', sa.INTEGER(), autoincrement=False, nullable=True))
|
||||
op.add_column('authorities', sa.Column('not_after', postgresql.TIMESTAMP(), autoincrement=False, nullable=True))
|
||||
op.alter_column('authorities', 'owner',
|
||||
existing_type=sa.VARCHAR(length=128),
|
||||
nullable=True)
|
||||
op.drop_constraint(None, "certificates", type_="foreignkey")
|
||||
op.drop_constraint(None, "certificates", type_="foreignkey")
|
||||
op.create_foreign_key(
|
||||
u"certificates_authority_id_fkey",
|
||||
"certificates",
|
||||
"authorities",
|
||||
["authority_id"],
|
||||
["id"],
|
||||
)
|
||||
op.alter_column(
|
||||
"certificates", "owner", existing_type=sa.VARCHAR(length=128), nullable=True
|
||||
)
|
||||
op.alter_column("certificates", "body", existing_type=sa.TEXT(), nullable=True)
|
||||
op.drop_column("certificates", "root_authority_id")
|
||||
op.add_column(
|
||||
"authorities",
|
||||
sa.Column(
|
||||
"not_before", postgresql.TIMESTAMP(), autoincrement=False, nullable=True
|
||||
),
|
||||
)
|
||||
op.add_column(
|
||||
"authorities",
|
||||
sa.Column("cn", sa.VARCHAR(length=128), autoincrement=False, nullable=True),
|
||||
)
|
||||
op.add_column(
|
||||
"authorities",
|
||||
sa.Column("bits", sa.INTEGER(), autoincrement=False, nullable=True),
|
||||
)
|
||||
op.add_column(
|
||||
"authorities",
|
||||
sa.Column(
|
||||
"not_after", postgresql.TIMESTAMP(), autoincrement=False, nullable=True
|
||||
),
|
||||
)
|
||||
op.alter_column(
|
||||
"authorities", "owner", existing_type=sa.VARCHAR(length=128), nullable=True
|
||||
)
|
||||
### end Alembic commands ###
|
||||
|
@ -7,25 +7,31 @@ Create Date: 2015-11-30 15:40:19.827272
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '33de094da890'
|
||||
revision = "33de094da890"
|
||||
down_revision = None
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('certificate_replacement_associations',
|
||||
sa.Column('replaced_certificate_id', sa.Integer(), nullable=True),
|
||||
sa.Column('certificate_id', sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['certificate_id'], ['certificates.id'], ondelete='cascade'),
|
||||
sa.ForeignKeyConstraint(['replaced_certificate_id'], ['certificates.id'], ondelete='cascade')
|
||||
op.create_table(
|
||||
"certificate_replacement_associations",
|
||||
sa.Column("replaced_certificate_id", sa.Integer(), nullable=True),
|
||||
sa.Column("certificate_id", sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(
|
||||
["certificate_id"], ["certificates.id"], ondelete="cascade"
|
||||
),
|
||||
sa.ForeignKeyConstraint(
|
||||
["replaced_certificate_id"], ["certificates.id"], ondelete="cascade"
|
||||
),
|
||||
)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('certificate_replacement_associations')
|
||||
op.drop_table("certificate_replacement_associations")
|
||||
### end Alembic commands ###
|
||||
|
@ -7,8 +7,8 @@ Create Date: 2018-04-10 13:25:47.007556
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '3adfdd6598df'
|
||||
down_revision = '556ceb3e3c3e'
|
||||
revision = "3adfdd6598df"
|
||||
down_revision = "556ceb3e3c3e"
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
@ -22,84 +22,90 @@ def upgrade():
|
||||
# create provider table
|
||||
print("Creating dns_providers table")
|
||||
op.create_table(
|
||||
'dns_providers',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('name', sa.String(length=256), nullable=True),
|
||||
sa.Column('description', sa.String(length=1024), nullable=True),
|
||||
sa.Column('provider_type', sa.String(length=256), nullable=True),
|
||||
sa.Column('credentials', Vault(), nullable=True),
|
||||
sa.Column('api_endpoint', sa.String(length=256), nullable=True),
|
||||
sa.Column('date_created', ArrowType(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('status', sa.String(length=128), nullable=True),
|
||||
sa.Column('options', JSON),
|
||||
sa.Column('domains', sa.JSON(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('name')
|
||||
"dns_providers",
|
||||
sa.Column("id", sa.Integer(), nullable=False),
|
||||
sa.Column("name", sa.String(length=256), nullable=True),
|
||||
sa.Column("description", sa.String(length=1024), nullable=True),
|
||||
sa.Column("provider_type", sa.String(length=256), nullable=True),
|
||||
sa.Column("credentials", Vault(), nullable=True),
|
||||
sa.Column("api_endpoint", sa.String(length=256), nullable=True),
|
||||
sa.Column(
|
||||
"date_created", ArrowType(), server_default=sa.text("now()"), nullable=False
|
||||
),
|
||||
sa.Column("status", sa.String(length=128), nullable=True),
|
||||
sa.Column("options", JSON),
|
||||
sa.Column("domains", sa.JSON(), nullable=True),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
sa.UniqueConstraint("name"),
|
||||
)
|
||||
print("Adding dns_provider_id column to certificates")
|
||||
op.add_column('certificates', sa.Column('dns_provider_id', sa.Integer(), nullable=True))
|
||||
op.add_column(
|
||||
"certificates", sa.Column("dns_provider_id", sa.Integer(), nullable=True)
|
||||
)
|
||||
print("Adding dns_provider_id column to pending_certs")
|
||||
op.add_column('pending_certs', sa.Column('dns_provider_id', sa.Integer(), nullable=True))
|
||||
op.add_column(
|
||||
"pending_certs", sa.Column("dns_provider_id", sa.Integer(), nullable=True)
|
||||
)
|
||||
print("Adding options column to pending_certs")
|
||||
op.add_column('pending_certs', sa.Column('options', JSON))
|
||||
op.add_column("pending_certs", sa.Column("options", JSON))
|
||||
|
||||
print("Creating pending_dns_authorizations table")
|
||||
op.create_table(
|
||||
'pending_dns_authorizations',
|
||||
sa.Column('id', sa.Integer(), primary_key=True, autoincrement=True),
|
||||
sa.Column('account_number', sa.String(length=128), nullable=True),
|
||||
sa.Column('domains', JSON, nullable=True),
|
||||
sa.Column('dns_provider_type', sa.String(length=128), nullable=True),
|
||||
sa.Column('options', JSON, nullable=True),
|
||||
"pending_dns_authorizations",
|
||||
sa.Column("id", sa.Integer(), primary_key=True, autoincrement=True),
|
||||
sa.Column("account_number", sa.String(length=128), nullable=True),
|
||||
sa.Column("domains", JSON, nullable=True),
|
||||
sa.Column("dns_provider_type", sa.String(length=128), nullable=True),
|
||||
sa.Column("options", JSON, nullable=True),
|
||||
)
|
||||
|
||||
print("Creating certificates_dns_providers_fk foreign key")
|
||||
op.create_foreign_key('certificates_dns_providers_fk', 'certificates', 'dns_providers', ['dns_provider_id'], ['id'],
|
||||
ondelete='cascade')
|
||||
op.create_foreign_key(
|
||||
"certificates_dns_providers_fk",
|
||||
"certificates",
|
||||
"dns_providers",
|
||||
["dns_provider_id"],
|
||||
["id"],
|
||||
ondelete="cascade",
|
||||
)
|
||||
|
||||
print("Altering column types in the api_keys table")
|
||||
op.alter_column('api_keys', 'issued_at',
|
||||
existing_type=sa.BIGINT(),
|
||||
nullable=True)
|
||||
op.alter_column('api_keys', 'revoked',
|
||||
existing_type=sa.BOOLEAN(),
|
||||
nullable=True)
|
||||
op.alter_column('api_keys', 'ttl',
|
||||
existing_type=sa.BIGINT(),
|
||||
nullable=True)
|
||||
op.alter_column('api_keys', 'user_id',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=True)
|
||||
op.alter_column("api_keys", "issued_at", existing_type=sa.BIGINT(), nullable=True)
|
||||
op.alter_column("api_keys", "revoked", existing_type=sa.BOOLEAN(), nullable=True)
|
||||
op.alter_column("api_keys", "ttl", existing_type=sa.BIGINT(), nullable=True)
|
||||
op.alter_column("api_keys", "user_id", existing_type=sa.INTEGER(), nullable=True)
|
||||
|
||||
print("Creating dns_providers_id foreign key on pending_certs table")
|
||||
op.create_foreign_key(None, 'pending_certs', 'dns_providers', ['dns_provider_id'], ['id'], ondelete='CASCADE')
|
||||
op.create_foreign_key(
|
||||
None,
|
||||
"pending_certs",
|
||||
"dns_providers",
|
||||
["dns_provider_id"],
|
||||
["id"],
|
||||
ondelete="CASCADE",
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
print("Removing dns_providers_id foreign key on pending_certs table")
|
||||
op.drop_constraint(None, 'pending_certs', type_='foreignkey')
|
||||
op.drop_constraint(None, "pending_certs", type_="foreignkey")
|
||||
print("Reverting column types in the api_keys table")
|
||||
op.alter_column('api_keys', 'user_id',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=False)
|
||||
op.alter_column('api_keys', 'ttl',
|
||||
existing_type=sa.BIGINT(),
|
||||
nullable=False)
|
||||
op.alter_column('api_keys', 'revoked',
|
||||
existing_type=sa.BOOLEAN(),
|
||||
nullable=False)
|
||||
op.alter_column('api_keys', 'issued_at',
|
||||
existing_type=sa.BIGINT(),
|
||||
nullable=False)
|
||||
op.alter_column("api_keys", "user_id", existing_type=sa.INTEGER(), nullable=False)
|
||||
op.alter_column("api_keys", "ttl", existing_type=sa.BIGINT(), nullable=False)
|
||||
op.alter_column("api_keys", "revoked", existing_type=sa.BOOLEAN(), nullable=False)
|
||||
op.alter_column("api_keys", "issued_at", existing_type=sa.BIGINT(), nullable=False)
|
||||
print("Reverting certificates_dns_providers_fk foreign key")
|
||||
op.drop_constraint('certificates_dns_providers_fk', 'certificates', type_='foreignkey')
|
||||
op.drop_constraint(
|
||||
"certificates_dns_providers_fk", "certificates", type_="foreignkey"
|
||||
)
|
||||
|
||||
print("Dropping pending_dns_authorizations table")
|
||||
op.drop_table('pending_dns_authorizations')
|
||||
op.drop_table("pending_dns_authorizations")
|
||||
print("Undoing modifications to pending_certs table")
|
||||
op.drop_column('pending_certs', 'options')
|
||||
op.drop_column('pending_certs', 'dns_provider_id')
|
||||
op.drop_column("pending_certs", "options")
|
||||
op.drop_column("pending_certs", "dns_provider_id")
|
||||
print("Undoing modifications to certificates table")
|
||||
op.drop_column('certificates', 'dns_provider_id')
|
||||
op.drop_column("certificates", "dns_provider_id")
|
||||
|
||||
print("Deleting dns_providers table")
|
||||
op.drop_table('dns_providers')
|
||||
op.drop_table("dns_providers")
|
||||
|
@ -7,8 +7,8 @@ Create Date: 2016-05-17 17:37:41.210232
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '412b22cb656a'
|
||||
down_revision = '4c50b903d1ae'
|
||||
revision = "412b22cb656a"
|
||||
down_revision = "4c50b903d1ae"
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
@ -17,47 +17,102 @@ from sqlalchemy.sql import text
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('roles_authorities',
|
||||
sa.Column('authority_id', sa.Integer(), nullable=True),
|
||||
sa.Column('role_id', sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['authority_id'], ['authorities.id'], ),
|
||||
sa.ForeignKeyConstraint(['role_id'], ['roles.id'], )
|
||||
op.create_table(
|
||||
"roles_authorities",
|
||||
sa.Column("authority_id", sa.Integer(), nullable=True),
|
||||
sa.Column("role_id", sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(["authority_id"], ["authorities.id"]),
|
||||
sa.ForeignKeyConstraint(["role_id"], ["roles.id"]),
|
||||
)
|
||||
op.create_index('roles_authorities_ix', 'roles_authorities', ['authority_id', 'role_id'], unique=True)
|
||||
op.create_table('roles_certificates',
|
||||
sa.Column('certificate_id', sa.Integer(), nullable=True),
|
||||
sa.Column('role_id', sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['certificate_id'], ['certificates.id'], ),
|
||||
sa.ForeignKeyConstraint(['role_id'], ['roles.id'], )
|
||||
op.create_index(
|
||||
"roles_authorities_ix",
|
||||
"roles_authorities",
|
||||
["authority_id", "role_id"],
|
||||
unique=True,
|
||||
)
|
||||
op.create_table(
|
||||
"roles_certificates",
|
||||
sa.Column("certificate_id", sa.Integer(), nullable=True),
|
||||
sa.Column("role_id", sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(["certificate_id"], ["certificates.id"]),
|
||||
sa.ForeignKeyConstraint(["role_id"], ["roles.id"]),
|
||||
)
|
||||
op.create_index(
|
||||
"roles_certificates_ix",
|
||||
"roles_certificates",
|
||||
["certificate_id", "role_id"],
|
||||
unique=True,
|
||||
)
|
||||
op.create_index(
|
||||
"certificate_associations_ix",
|
||||
"certificate_associations",
|
||||
["domain_id", "certificate_id"],
|
||||
unique=True,
|
||||
)
|
||||
op.create_index(
|
||||
"certificate_destination_associations_ix",
|
||||
"certificate_destination_associations",
|
||||
["destination_id", "certificate_id"],
|
||||
unique=True,
|
||||
)
|
||||
op.create_index(
|
||||
"certificate_notification_associations_ix",
|
||||
"certificate_notification_associations",
|
||||
["notification_id", "certificate_id"],
|
||||
unique=True,
|
||||
)
|
||||
op.create_index(
|
||||
"certificate_replacement_associations_ix",
|
||||
"certificate_replacement_associations",
|
||||
["certificate_id", "certificate_id"],
|
||||
unique=True,
|
||||
)
|
||||
op.create_index(
|
||||
"certificate_source_associations_ix",
|
||||
"certificate_source_associations",
|
||||
["source_id", "certificate_id"],
|
||||
unique=True,
|
||||
)
|
||||
op.create_index(
|
||||
"roles_users_ix", "roles_users", ["user_id", "role_id"], unique=True
|
||||
)
|
||||
op.create_index('roles_certificates_ix', 'roles_certificates', ['certificate_id', 'role_id'], unique=True)
|
||||
op.create_index('certificate_associations_ix', 'certificate_associations', ['domain_id', 'certificate_id'], unique=True)
|
||||
op.create_index('certificate_destination_associations_ix', 'certificate_destination_associations', ['destination_id', 'certificate_id'], unique=True)
|
||||
op.create_index('certificate_notification_associations_ix', 'certificate_notification_associations', ['notification_id', 'certificate_id'], unique=True)
|
||||
op.create_index('certificate_replacement_associations_ix', 'certificate_replacement_associations', ['certificate_id', 'certificate_id'], unique=True)
|
||||
op.create_index('certificate_source_associations_ix', 'certificate_source_associations', ['source_id', 'certificate_id'], unique=True)
|
||||
op.create_index('roles_users_ix', 'roles_users', ['user_id', 'role_id'], unique=True)
|
||||
|
||||
### end Alembic commands ###
|
||||
|
||||
# migrate existing authority_id relationship to many_to_many
|
||||
conn = op.get_bind()
|
||||
for id, authority_id in conn.execute(text('select id, authority_id from roles where authority_id is not null')):
|
||||
stmt = text('insert into roles_authoritties (role_id, authority_id) values (:role_id, :authority_id)')
|
||||
for id, authority_id in conn.execute(
|
||||
text("select id, authority_id from roles where authority_id is not null")
|
||||
):
|
||||
stmt = text(
|
||||
"insert into roles_authoritties (role_id, authority_id) values (:role_id, :authority_id)"
|
||||
)
|
||||
stmt = stmt.bindparams(role_id=id, authority_id=authority_id)
|
||||
op.execute(stmt)
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index('roles_users_ix', table_name='roles_users')
|
||||
op.drop_index('certificate_source_associations_ix', table_name='certificate_source_associations')
|
||||
op.drop_index('certificate_replacement_associations_ix', table_name='certificate_replacement_associations')
|
||||
op.drop_index('certificate_notification_associations_ix', table_name='certificate_notification_associations')
|
||||
op.drop_index('certificate_destination_associations_ix', table_name='certificate_destination_associations')
|
||||
op.drop_index('certificate_associations_ix', table_name='certificate_associations')
|
||||
op.drop_index('roles_certificates_ix', table_name='roles_certificates')
|
||||
op.drop_table('roles_certificates')
|
||||
op.drop_index('roles_authorities_ix', table_name='roles_authorities')
|
||||
op.drop_table('roles_authorities')
|
||||
op.drop_index("roles_users_ix", table_name="roles_users")
|
||||
op.drop_index(
|
||||
"certificate_source_associations_ix",
|
||||
table_name="certificate_source_associations",
|
||||
)
|
||||
op.drop_index(
|
||||
"certificate_replacement_associations_ix",
|
||||
table_name="certificate_replacement_associations",
|
||||
)
|
||||
op.drop_index(
|
||||
"certificate_notification_associations_ix",
|
||||
table_name="certificate_notification_associations",
|
||||
)
|
||||
op.drop_index(
|
||||
"certificate_destination_associations_ix",
|
||||
table_name="certificate_destination_associations",
|
||||
)
|
||||
op.drop_index("certificate_associations_ix", table_name="certificate_associations")
|
||||
op.drop_index("roles_certificates_ix", table_name="roles_certificates")
|
||||
op.drop_table("roles_certificates")
|
||||
op.drop_index("roles_authorities_ix", table_name="roles_authorities")
|
||||
op.drop_table("roles_authorities")
|
||||
### end Alembic commands ###
|
||||
|
@ -7,8 +7,8 @@ Create Date: 2018-02-24 22:51:35.369229
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '449c3d5c7299'
|
||||
down_revision = '5770674184de'
|
||||
revision = "449c3d5c7299"
|
||||
down_revision = "5770674184de"
|
||||
|
||||
from alembic import op
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
@ -23,12 +23,14 @@ COLUMNS = ["notification_id", "certificate_id"]
|
||||
def upgrade():
|
||||
connection = op.get_bind()
|
||||
# Delete duplicate entries
|
||||
connection.execute("""\
|
||||
connection.execute(
|
||||
"""\
|
||||
DELETE FROM certificate_notification_associations WHERE ctid NOT IN (
|
||||
-- Select the first tuple ID for each (notification_id, certificate_id) combination and keep that
|
||||
SELECT min(ctid) FROM certificate_notification_associations GROUP BY notification_id, certificate_id
|
||||
)
|
||||
""")
|
||||
"""
|
||||
)
|
||||
op.create_unique_constraint(CONSTRAINT_NAME, TABLE, COLUMNS)
|
||||
|
||||
|
||||
|
@ -7,20 +7,21 @@ Create Date: 2015-12-30 10:19:30.057791
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '4c50b903d1ae'
|
||||
down_revision = '33de094da890'
|
||||
revision = "4c50b903d1ae"
|
||||
down_revision = "33de094da890"
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('domains', sa.Column('sensitive', sa.Boolean(), nullable=True))
|
||||
op.add_column("domains", sa.Column("sensitive", sa.Boolean(), nullable=True))
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('domains', 'sensitive')
|
||||
op.drop_column("domains", "sensitive")
|
||||
### end Alembic commands ###
|
||||
|
@ -7,8 +7,8 @@ Create Date: 2018-01-05 01:18:45.571595
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '556ceb3e3c3e'
|
||||
down_revision = '449c3d5c7299'
|
||||
revision = "556ceb3e3c3e"
|
||||
down_revision = "449c3d5c7299"
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
@ -16,84 +16,150 @@ from lemur.utils import Vault
|
||||
from sqlalchemy.dialects import postgresql
|
||||
from sqlalchemy_utils import ArrowType
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('pending_certs',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('external_id', sa.String(length=128), nullable=True),
|
||||
sa.Column('owner', sa.String(length=128), nullable=False),
|
||||
sa.Column('name', sa.String(length=256), nullable=True),
|
||||
sa.Column('description', sa.String(length=1024), nullable=True),
|
||||
sa.Column('notify', sa.Boolean(), nullable=True),
|
||||
sa.Column('number_attempts', sa.Integer(), nullable=True),
|
||||
sa.Column('rename', sa.Boolean(), nullable=True),
|
||||
sa.Column('cn', sa.String(length=128), nullable=True),
|
||||
sa.Column('csr', sa.Text(), nullable=False),
|
||||
sa.Column('chain', sa.Text(), nullable=True),
|
||||
sa.Column('private_key', Vault(), nullable=True),
|
||||
sa.Column('date_created', ArrowType(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('status', sa.String(length=128), nullable=True),
|
||||
sa.Column('rotation', sa.Boolean(), nullable=True),
|
||||
sa.Column('user_id', sa.Integer(), nullable=True),
|
||||
sa.Column('authority_id', sa.Integer(), nullable=True),
|
||||
sa.Column('root_authority_id', sa.Integer(), nullable=True),
|
||||
sa.Column('rotation_policy_id', sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['authority_id'], ['authorities.id'], ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['root_authority_id'], ['authorities.id'], ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['rotation_policy_id'], ['rotation_policies.id'], ),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('name')
|
||||
op.create_table(
|
||||
"pending_certs",
|
||||
sa.Column("id", sa.Integer(), nullable=False),
|
||||
sa.Column("external_id", sa.String(length=128), nullable=True),
|
||||
sa.Column("owner", sa.String(length=128), nullable=False),
|
||||
sa.Column("name", sa.String(length=256), nullable=True),
|
||||
sa.Column("description", sa.String(length=1024), nullable=True),
|
||||
sa.Column("notify", sa.Boolean(), nullable=True),
|
||||
sa.Column("number_attempts", sa.Integer(), nullable=True),
|
||||
sa.Column("rename", sa.Boolean(), nullable=True),
|
||||
sa.Column("cn", sa.String(length=128), nullable=True),
|
||||
sa.Column("csr", sa.Text(), nullable=False),
|
||||
sa.Column("chain", sa.Text(), nullable=True),
|
||||
sa.Column("private_key", Vault(), nullable=True),
|
||||
sa.Column(
|
||||
"date_created", ArrowType(), server_default=sa.text("now()"), nullable=False
|
||||
),
|
||||
sa.Column("status", sa.String(length=128), nullable=True),
|
||||
sa.Column("rotation", sa.Boolean(), nullable=True),
|
||||
sa.Column("user_id", sa.Integer(), nullable=True),
|
||||
sa.Column("authority_id", sa.Integer(), nullable=True),
|
||||
sa.Column("root_authority_id", sa.Integer(), nullable=True),
|
||||
sa.Column("rotation_policy_id", sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(
|
||||
["authority_id"], ["authorities.id"], ondelete="CASCADE"
|
||||
),
|
||||
sa.ForeignKeyConstraint(
|
||||
["root_authority_id"], ["authorities.id"], ondelete="CASCADE"
|
||||
),
|
||||
sa.ForeignKeyConstraint(["rotation_policy_id"], ["rotation_policies.id"]),
|
||||
sa.ForeignKeyConstraint(["user_id"], ["users.id"]),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
sa.UniqueConstraint("name"),
|
||||
)
|
||||
op.create_table('pending_cert_destination_associations',
|
||||
sa.Column('destination_id', sa.Integer(), nullable=True),
|
||||
sa.Column('pending_cert_id', sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['destination_id'], ['destinations.id'], ondelete='cascade'),
|
||||
sa.ForeignKeyConstraint(['pending_cert_id'], ['pending_certs.id'], ondelete='cascade')
|
||||
op.create_table(
|
||||
"pending_cert_destination_associations",
|
||||
sa.Column("destination_id", sa.Integer(), nullable=True),
|
||||
sa.Column("pending_cert_id", sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(
|
||||
["destination_id"], ["destinations.id"], ondelete="cascade"
|
||||
),
|
||||
sa.ForeignKeyConstraint(
|
||||
["pending_cert_id"], ["pending_certs.id"], ondelete="cascade"
|
||||
),
|
||||
)
|
||||
op.create_index('pending_cert_destination_associations_ix', 'pending_cert_destination_associations', ['destination_id', 'pending_cert_id'], unique=False)
|
||||
op.create_table('pending_cert_notification_associations',
|
||||
sa.Column('notification_id', sa.Integer(), nullable=True),
|
||||
sa.Column('pending_cert_id', sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['notification_id'], ['notifications.id'], ondelete='cascade'),
|
||||
sa.ForeignKeyConstraint(['pending_cert_id'], ['pending_certs.id'], ondelete='cascade')
|
||||
op.create_index(
|
||||
"pending_cert_destination_associations_ix",
|
||||
"pending_cert_destination_associations",
|
||||
["destination_id", "pending_cert_id"],
|
||||
unique=False,
|
||||
)
|
||||
op.create_index('pending_cert_notification_associations_ix', 'pending_cert_notification_associations', ['notification_id', 'pending_cert_id'], unique=False)
|
||||
op.create_table('pending_cert_replacement_associations',
|
||||
sa.Column('replaced_certificate_id', sa.Integer(), nullable=True),
|
||||
sa.Column('pending_cert_id', sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['pending_cert_id'], ['pending_certs.id'], ondelete='cascade'),
|
||||
sa.ForeignKeyConstraint(['replaced_certificate_id'], ['certificates.id'], ondelete='cascade')
|
||||
op.create_table(
|
||||
"pending_cert_notification_associations",
|
||||
sa.Column("notification_id", sa.Integer(), nullable=True),
|
||||
sa.Column("pending_cert_id", sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(
|
||||
["notification_id"], ["notifications.id"], ondelete="cascade"
|
||||
),
|
||||
sa.ForeignKeyConstraint(
|
||||
["pending_cert_id"], ["pending_certs.id"], ondelete="cascade"
|
||||
),
|
||||
)
|
||||
op.create_index('pending_cert_replacement_associations_ix', 'pending_cert_replacement_associations', ['replaced_certificate_id', 'pending_cert_id'], unique=False)
|
||||
op.create_table('pending_cert_role_associations',
|
||||
sa.Column('pending_cert_id', sa.Integer(), nullable=True),
|
||||
sa.Column('role_id', sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['pending_cert_id'], ['pending_certs.id'], ),
|
||||
sa.ForeignKeyConstraint(['role_id'], ['roles.id'], )
|
||||
op.create_index(
|
||||
"pending_cert_notification_associations_ix",
|
||||
"pending_cert_notification_associations",
|
||||
["notification_id", "pending_cert_id"],
|
||||
unique=False,
|
||||
)
|
||||
op.create_index('pending_cert_role_associations_ix', 'pending_cert_role_associations', ['pending_cert_id', 'role_id'], unique=False)
|
||||
op.create_table('pending_cert_source_associations',
|
||||
sa.Column('source_id', sa.Integer(), nullable=True),
|
||||
sa.Column('pending_cert_id', sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['pending_cert_id'], ['pending_certs.id'], ondelete='cascade'),
|
||||
sa.ForeignKeyConstraint(['source_id'], ['sources.id'], ondelete='cascade')
|
||||
op.create_table(
|
||||
"pending_cert_replacement_associations",
|
||||
sa.Column("replaced_certificate_id", sa.Integer(), nullable=True),
|
||||
sa.Column("pending_cert_id", sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(
|
||||
["pending_cert_id"], ["pending_certs.id"], ondelete="cascade"
|
||||
),
|
||||
sa.ForeignKeyConstraint(
|
||||
["replaced_certificate_id"], ["certificates.id"], ondelete="cascade"
|
||||
),
|
||||
)
|
||||
op.create_index(
|
||||
"pending_cert_replacement_associations_ix",
|
||||
"pending_cert_replacement_associations",
|
||||
["replaced_certificate_id", "pending_cert_id"],
|
||||
unique=False,
|
||||
)
|
||||
op.create_table(
|
||||
"pending_cert_role_associations",
|
||||
sa.Column("pending_cert_id", sa.Integer(), nullable=True),
|
||||
sa.Column("role_id", sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(["pending_cert_id"], ["pending_certs.id"]),
|
||||
sa.ForeignKeyConstraint(["role_id"], ["roles.id"]),
|
||||
)
|
||||
op.create_index(
|
||||
"pending_cert_role_associations_ix",
|
||||
"pending_cert_role_associations",
|
||||
["pending_cert_id", "role_id"],
|
||||
unique=False,
|
||||
)
|
||||
op.create_table(
|
||||
"pending_cert_source_associations",
|
||||
sa.Column("source_id", sa.Integer(), nullable=True),
|
||||
sa.Column("pending_cert_id", sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(
|
||||
["pending_cert_id"], ["pending_certs.id"], ondelete="cascade"
|
||||
),
|
||||
sa.ForeignKeyConstraint(["source_id"], ["sources.id"], ondelete="cascade"),
|
||||
)
|
||||
op.create_index(
|
||||
"pending_cert_source_associations_ix",
|
||||
"pending_cert_source_associations",
|
||||
["source_id", "pending_cert_id"],
|
||||
unique=False,
|
||||
)
|
||||
op.create_index('pending_cert_source_associations_ix', 'pending_cert_source_associations', ['source_id', 'pending_cert_id'], unique=False)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index('pending_cert_source_associations_ix', table_name='pending_cert_source_associations')
|
||||
op.drop_table('pending_cert_source_associations')
|
||||
op.drop_index('pending_cert_role_associations_ix', table_name='pending_cert_role_associations')
|
||||
op.drop_table('pending_cert_role_associations')
|
||||
op.drop_index('pending_cert_replacement_associations_ix', table_name='pending_cert_replacement_associations')
|
||||
op.drop_table('pending_cert_replacement_associations')
|
||||
op.drop_index('pending_cert_notification_associations_ix', table_name='pending_cert_notification_associations')
|
||||
op.drop_table('pending_cert_notification_associations')
|
||||
op.drop_index('pending_cert_destination_associations_ix', table_name='pending_cert_destination_associations')
|
||||
op.drop_table('pending_cert_destination_associations')
|
||||
op.drop_table('pending_certs')
|
||||
op.drop_index(
|
||||
"pending_cert_source_associations_ix",
|
||||
table_name="pending_cert_source_associations",
|
||||
)
|
||||
op.drop_table("pending_cert_source_associations")
|
||||
op.drop_index(
|
||||
"pending_cert_role_associations_ix", table_name="pending_cert_role_associations"
|
||||
)
|
||||
op.drop_table("pending_cert_role_associations")
|
||||
op.drop_index(
|
||||
"pending_cert_replacement_associations_ix",
|
||||
table_name="pending_cert_replacement_associations",
|
||||
)
|
||||
op.drop_table("pending_cert_replacement_associations")
|
||||
op.drop_index(
|
||||
"pending_cert_notification_associations_ix",
|
||||
table_name="pending_cert_notification_associations",
|
||||
)
|
||||
op.drop_table("pending_cert_notification_associations")
|
||||
op.drop_index(
|
||||
"pending_cert_destination_associations_ix",
|
||||
table_name="pending_cert_destination_associations",
|
||||
)
|
||||
op.drop_table("pending_cert_destination_associations")
|
||||
op.drop_table("pending_certs")
|
||||
# ### end Alembic commands ###
|
||||
|
@ -7,8 +7,8 @@ Create Date: 2018-02-23 15:27:30.335435
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '5770674184de'
|
||||
down_revision = 'ce547319f7be'
|
||||
revision = "5770674184de"
|
||||
down_revision = "ce547319f7be"
|
||||
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
from lemur.models import certificate_notification_associations
|
||||
@ -32,7 +32,9 @@ def upgrade():
|
||||
# If we've seen a pair already, delete the duplicates
|
||||
if seen.get("{}-{}".format(x.certificate_id, x.notification_id)):
|
||||
print("Deleting duplicate: {}".format(x))
|
||||
d = session.query(certificate_notification_associations).filter(certificate_notification_associations.c.id==x.id)
|
||||
d = session.query(certificate_notification_associations).filter(
|
||||
certificate_notification_associations.c.id == x.id
|
||||
)
|
||||
d.delete(synchronize_session=False)
|
||||
seen["{}-{}".format(x.certificate_id, x.notification_id)] = True
|
||||
db.session.commit()
|
||||
|
@ -7,8 +7,8 @@ Create Date: 2018-08-14 08:16:43.329316
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '5ae0ecefb01f'
|
||||
down_revision = '1db4f82bc780'
|
||||
revision = "5ae0ecefb01f"
|
||||
down_revision = "1db4f82bc780"
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
@ -16,17 +16,14 @@ import sqlalchemy as sa
|
||||
|
||||
def upgrade():
|
||||
op.alter_column(
|
||||
table_name='pending_certs',
|
||||
column_name='status',
|
||||
nullable=True,
|
||||
type_=sa.TEXT()
|
||||
table_name="pending_certs", column_name="status", nullable=True, type_=sa.TEXT()
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.alter_column(
|
||||
table_name='pending_certs',
|
||||
column_name='status',
|
||||
table_name="pending_certs",
|
||||
column_name="status",
|
||||
nullable=True,
|
||||
type_=sa.VARCHAR(128)
|
||||
type_=sa.VARCHAR(128),
|
||||
)
|
||||
|
@ -7,16 +7,18 @@ Create Date: 2017-12-08 14:19:11.903864
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '5bc47fa7cac4'
|
||||
down_revision = 'c05a8998b371'
|
||||
revision = "5bc47fa7cac4"
|
||||
down_revision = "c05a8998b371"
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.add_column('roles', sa.Column('third_party', sa.Boolean(), nullable=True, default=False))
|
||||
op.add_column(
|
||||
"roles", sa.Column("third_party", sa.Boolean(), nullable=True, default=False)
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_column('roles', 'third_party')
|
||||
op.drop_column("roles", "third_party")
|
||||
|
@ -7,20 +7,20 @@ Create Date: 2017-01-26 05:05:25.168125
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '5e680529b666'
|
||||
down_revision = '131ec6accff5'
|
||||
revision = "5e680529b666"
|
||||
down_revision = "131ec6accff5"
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.add_column('endpoints', sa.Column('sensitive', sa.Boolean(), nullable=True))
|
||||
op.add_column('endpoints', sa.Column('source_id', sa.Integer(), nullable=True))
|
||||
op.create_foreign_key(None, 'endpoints', 'sources', ['source_id'], ['id'])
|
||||
op.add_column("endpoints", sa.Column("sensitive", sa.Boolean(), nullable=True))
|
||||
op.add_column("endpoints", sa.Column("source_id", sa.Integer(), nullable=True))
|
||||
op.create_foreign_key(None, "endpoints", "sources", ["source_id"], ["id"])
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_constraint(None, 'endpoints', type_='foreignkey')
|
||||
op.drop_column('endpoints', 'source_id')
|
||||
op.drop_column('endpoints', 'sensitive')
|
||||
op.drop_constraint(None, "endpoints", type_="foreignkey")
|
||||
op.drop_column("endpoints", "source_id")
|
||||
op.drop_column("endpoints", "sensitive")
|
||||
|
@ -7,15 +7,15 @@ Create Date: 2018-10-19 15:23:06.750510
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '6006c79b6011'
|
||||
down_revision = '984178255c83'
|
||||
revision = "6006c79b6011"
|
||||
down_revision = "984178255c83"
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.create_unique_constraint("uq_label", 'sources', ['label'])
|
||||
op.create_unique_constraint("uq_label", "sources", ["label"])
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_constraint("uq_label", 'sources', type_='unique')
|
||||
op.drop_constraint("uq_label", "sources", type_="unique")
|
||||
|
@ -7,15 +7,16 @@ Create Date: 2018-10-21 22:06:23.056906
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '7ead443ba911'
|
||||
down_revision = '6006c79b6011'
|
||||
revision = "7ead443ba911"
|
||||
down_revision = "6006c79b6011"
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.add_column('certificates', sa.Column('csr', sa.TEXT(), nullable=True))
|
||||
op.add_column("certificates", sa.Column("csr", sa.TEXT(), nullable=True))
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_column('certificates', 'csr')
|
||||
op.drop_column("certificates", "csr")
|
||||
|
@ -9,8 +9,8 @@ Create Date: 2016-07-28 09:39:12.736506
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '7f71c0cea31a'
|
||||
down_revision = '29d8c8455c86'
|
||||
revision = "7f71c0cea31a"
|
||||
down_revision = "29d8c8455c86"
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
@ -19,17 +19,25 @@ from sqlalchemy.sql import text
|
||||
|
||||
def upgrade():
|
||||
conn = op.get_bind()
|
||||
for name in conn.execute(text('select name from certificates group by name having count(*) > 1')):
|
||||
for idx, id in enumerate(conn.execute(text("select id from certificates where certificates.name like :name order by id ASC").bindparams(name=name[0]))):
|
||||
for name in conn.execute(
|
||||
text("select name from certificates group by name having count(*) > 1")
|
||||
):
|
||||
for idx, id in enumerate(
|
||||
conn.execute(
|
||||
text(
|
||||
"select id from certificates where certificates.name like :name order by id ASC"
|
||||
).bindparams(name=name[0])
|
||||
)
|
||||
):
|
||||
if not idx:
|
||||
continue
|
||||
new_name = name[0] + '-' + str(idx)
|
||||
stmt = text('update certificates set name=:name where id=:id')
|
||||
new_name = name[0] + "-" + str(idx)
|
||||
stmt = text("update certificates set name=:name where id=:id")
|
||||
stmt = stmt.bindparams(name=new_name, id=id[0])
|
||||
op.execute(stmt)
|
||||
|
||||
op.create_unique_constraint(None, 'certificates', ['name'])
|
||||
op.create_unique_constraint(None, "certificates", ["name"])
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_constraint(None, 'certificates', type_='unique')
|
||||
op.drop_constraint(None, "certificates", type_="unique")
|
||||
|
@ -7,18 +7,28 @@ Create Date: 2017-05-10 11:56:13.999332
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '8ae67285ff14'
|
||||
down_revision = '5e680529b666'
|
||||
revision = "8ae67285ff14"
|
||||
down_revision = "5e680529b666"
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.drop_index('certificate_replacement_associations_ix')
|
||||
op.create_index('certificate_replacement_associations_ix', 'certificate_replacement_associations', ['replaced_certificate_id', 'certificate_id'], unique=True)
|
||||
op.drop_index("certificate_replacement_associations_ix")
|
||||
op.create_index(
|
||||
"certificate_replacement_associations_ix",
|
||||
"certificate_replacement_associations",
|
||||
["replaced_certificate_id", "certificate_id"],
|
||||
unique=True,
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_index('certificate_replacement_associations_ix')
|
||||
op.create_index('certificate_replacement_associations_ix', 'certificate_replacement_associations', ['certificate_id', 'certificate_id'], unique=True)
|
||||
op.drop_index("certificate_replacement_associations_ix")
|
||||
op.create_index(
|
||||
"certificate_replacement_associations_ix",
|
||||
"certificate_replacement_associations",
|
||||
["certificate_id", "certificate_id"],
|
||||
unique=True,
|
||||
)
|
||||
|
@ -7,15 +7,15 @@ Create Date: 2016-10-13 20:14:33.928029
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '932525b82f1a'
|
||||
down_revision = '7f71c0cea31a'
|
||||
revision = "932525b82f1a"
|
||||
down_revision = "7f71c0cea31a"
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.alter_column('certificates', 'active', new_column_name='notify')
|
||||
op.alter_column("certificates", "active", new_column_name="notify")
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.alter_column('certificates', 'notify', new_column_name='active')
|
||||
op.alter_column("certificates", "notify", new_column_name="active")
|
||||
|
@ -6,8 +6,8 @@ Create Date: 2018-09-17 08:33:37.087488
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '9392b9f9a805'
|
||||
down_revision = '5ae0ecefb01f'
|
||||
revision = "9392b9f9a805"
|
||||
down_revision = "5ae0ecefb01f"
|
||||
|
||||
from alembic import op
|
||||
from sqlalchemy_utils import ArrowType
|
||||
@ -15,10 +15,17 @@ import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.add_column('pending_certs', sa.Column('last_updated', ArrowType, server_default=sa.text('now()'), onupdate=sa.text('now()'),
|
||||
nullable=False))
|
||||
op.add_column(
|
||||
"pending_certs",
|
||||
sa.Column(
|
||||
"last_updated",
|
||||
ArrowType,
|
||||
server_default=sa.text("now()"),
|
||||
onupdate=sa.text("now()"),
|
||||
nullable=False,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_column('pending_certs', 'last_updated')
|
||||
|
||||
op.drop_column("pending_certs", "last_updated")
|
||||
|
@ -7,18 +7,20 @@ Create Date: 2018-10-11 20:49:12.704563
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '984178255c83'
|
||||
down_revision = 'f2383bf08fbc'
|
||||
revision = "984178255c83"
|
||||
down_revision = "f2383bf08fbc"
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.add_column('pending_certs', sa.Column('resolved', sa.Boolean(), nullable=True))
|
||||
op.add_column('pending_certs', sa.Column('resolved_cert_id', sa.Integer(), nullable=True))
|
||||
op.add_column("pending_certs", sa.Column("resolved", sa.Boolean(), nullable=True))
|
||||
op.add_column(
|
||||
"pending_certs", sa.Column("resolved_cert_id", sa.Integer(), nullable=True)
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_column('pending_certs', 'resolved_cert_id')
|
||||
op.drop_column('pending_certs', 'resolved')
|
||||
op.drop_column("pending_certs", "resolved_cert_id")
|
||||
op.drop_column("pending_certs", "resolved")
|
||||
|
@ -7,16 +7,26 @@ Create Date: 2019-01-03 15:36:59.181911
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '9f79024fe67b'
|
||||
down_revision = 'ee827d1e1974'
|
||||
revision = "9f79024fe67b"
|
||||
down_revision = "ee827d1e1974"
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.sync_enum_values('public', 'log_type', ['create_cert', 'key_view', 'revoke_cert', 'update_cert'], ['create_cert', 'delete_cert', 'key_view', 'revoke_cert', 'update_cert'])
|
||||
op.sync_enum_values(
|
||||
"public",
|
||||
"log_type",
|
||||
["create_cert", "key_view", "revoke_cert", "update_cert"],
|
||||
["create_cert", "delete_cert", "key_view", "revoke_cert", "update_cert"],
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.sync_enum_values('public', 'log_type', ['create_cert', 'delete_cert', 'key_view', 'revoke_cert', 'update_cert'], ['create_cert', 'key_view', 'revoke_cert', 'update_cert'])
|
||||
op.sync_enum_values(
|
||||
"public",
|
||||
"log_type",
|
||||
["create_cert", "delete_cert", "key_view", "revoke_cert", "update_cert"],
|
||||
["create_cert", "key_view", "revoke_cert", "update_cert"],
|
||||
)
|
||||
|
@ -10,8 +10,8 @@ Create Date: 2017-07-12 11:45:49.257927
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'a02a678ddc25'
|
||||
down_revision = '8ae67285ff14'
|
||||
revision = "a02a678ddc25"
|
||||
down_revision = "8ae67285ff14"
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
@ -20,25 +20,30 @@ from sqlalchemy.sql import text
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('rotation_policies',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('name', sa.String(), nullable=True),
|
||||
sa.Column('days', sa.Integer(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
op.create_table(
|
||||
"rotation_policies",
|
||||
sa.Column("id", sa.Integer(), nullable=False),
|
||||
sa.Column("name", sa.String(), nullable=True),
|
||||
sa.Column("days", sa.Integer(), nullable=True),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
op.add_column(
|
||||
"certificates", sa.Column("rotation_policy_id", sa.Integer(), nullable=True)
|
||||
)
|
||||
op.create_foreign_key(
|
||||
None, "certificates", "rotation_policies", ["rotation_policy_id"], ["id"]
|
||||
)
|
||||
op.add_column('certificates', sa.Column('rotation_policy_id', sa.Integer(), nullable=True))
|
||||
op.create_foreign_key(None, 'certificates', 'rotation_policies', ['rotation_policy_id'], ['id'])
|
||||
|
||||
conn = op.get_bind()
|
||||
stmt = text('insert into rotation_policies (days, name) values (:days, :name)')
|
||||
stmt = stmt.bindparams(days=30, name='default')
|
||||
stmt = text("insert into rotation_policies (days, name) values (:days, :name)")
|
||||
stmt = stmt.bindparams(days=30, name="default")
|
||||
conn.execute(stmt)
|
||||
|
||||
stmt = text('select id from rotation_policies where name=:name')
|
||||
stmt = stmt.bindparams(name='default')
|
||||
stmt = text("select id from rotation_policies where name=:name")
|
||||
stmt = stmt.bindparams(name="default")
|
||||
rotation_policy_id = conn.execute(stmt).fetchone()[0]
|
||||
|
||||
stmt = text('update certificates set rotation_policy_id=:rotation_policy_id')
|
||||
stmt = text("update certificates set rotation_policy_id=:rotation_policy_id")
|
||||
stmt = stmt.bindparams(rotation_policy_id=rotation_policy_id)
|
||||
conn.execute(stmt)
|
||||
# ### end Alembic commands ###
|
||||
@ -46,9 +51,17 @@ def upgrade():
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint(None, 'certificates', type_='foreignkey')
|
||||
op.drop_column('certificates', 'rotation_policy_id')
|
||||
op.drop_index('certificate_replacement_associations_ix', table_name='certificate_replacement_associations')
|
||||
op.create_index('certificate_replacement_associations_ix', 'certificate_replacement_associations', ['replaced_certificate_id', 'certificate_id'], unique=True)
|
||||
op.drop_table('rotation_policies')
|
||||
op.drop_constraint(None, "certificates", type_="foreignkey")
|
||||
op.drop_column("certificates", "rotation_policy_id")
|
||||
op.drop_index(
|
||||
"certificate_replacement_associations_ix",
|
||||
table_name="certificate_replacement_associations",
|
||||
)
|
||||
op.create_index(
|
||||
"certificate_replacement_associations_ix",
|
||||
"certificate_replacement_associations",
|
||||
["replaced_certificate_id", "certificate_id"],
|
||||
unique=True,
|
||||
)
|
||||
op.drop_table("rotation_policies")
|
||||
# ### end Alembic commands ###
|
||||
|
@ -7,8 +7,8 @@ Create Date: 2017-10-11 10:16:39.682591
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'ac483cfeb230'
|
||||
down_revision = 'b29e2c4bf8c9'
|
||||
revision = "ac483cfeb230"
|
||||
down_revision = "b29e2c4bf8c9"
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
@ -16,12 +16,18 @@ from sqlalchemy.dialects import postgresql
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.alter_column('certificates', 'name',
|
||||
existing_type=sa.VARCHAR(length=128),
|
||||
type_=sa.String(length=256))
|
||||
op.alter_column(
|
||||
"certificates",
|
||||
"name",
|
||||
existing_type=sa.VARCHAR(length=128),
|
||||
type_=sa.String(length=256),
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.alter_column('certificates', 'name',
|
||||
existing_type=sa.VARCHAR(length=256),
|
||||
type_=sa.String(length=128))
|
||||
op.alter_column(
|
||||
"certificates",
|
||||
"name",
|
||||
existing_type=sa.VARCHAR(length=256),
|
||||
type_=sa.String(length=128),
|
||||
)
|
||||
|
@ -7,8 +7,8 @@ Create Date: 2017-09-26 10:50:35.740367
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'b29e2c4bf8c9'
|
||||
down_revision = '1ae8e3104db8'
|
||||
revision = "b29e2c4bf8c9"
|
||||
down_revision = "1ae8e3104db8"
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
@ -16,13 +16,25 @@ import sqlalchemy as sa
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('certificates', sa.Column('external_id', sa.String(128), nullable=True))
|
||||
op.sync_enum_values('public', 'log_type', ['create_cert', 'key_view', 'update_cert'], ['create_cert', 'key_view', 'revoke_cert', 'update_cert'])
|
||||
op.add_column(
|
||||
"certificates", sa.Column("external_id", sa.String(128), nullable=True)
|
||||
)
|
||||
op.sync_enum_values(
|
||||
"public",
|
||||
"log_type",
|
||||
["create_cert", "key_view", "update_cert"],
|
||||
["create_cert", "key_view", "revoke_cert", "update_cert"],
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.sync_enum_values('public', 'log_type', ['create_cert', 'key_view', 'revoke_cert', 'update_cert'], ['create_cert', 'key_view', 'update_cert'])
|
||||
op.drop_column('certificates', 'external_id')
|
||||
op.sync_enum_values(
|
||||
"public",
|
||||
"log_type",
|
||||
["create_cert", "key_view", "revoke_cert", "update_cert"],
|
||||
["create_cert", "key_view", "update_cert"],
|
||||
)
|
||||
op.drop_column("certificates", "external_id")
|
||||
# ### end Alembic commands ###
|
||||
|
@ -7,25 +7,27 @@ Create Date: 2017-11-10 14:51:28.975927
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'c05a8998b371'
|
||||
down_revision = 'ac483cfeb230'
|
||||
revision = "c05a8998b371"
|
||||
down_revision = "ac483cfeb230"
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
import sqlalchemy_utils
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.create_table('api_keys',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('name', sa.String(length=128), nullable=True),
|
||||
sa.Column('user_id', sa.Integer(), nullable=False),
|
||||
sa.Column('ttl', sa.BigInteger(), nullable=False),
|
||||
sa.Column('issued_at', sa.BigInteger(), nullable=False),
|
||||
sa.Column('revoked', sa.Boolean(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
op.create_table(
|
||||
"api_keys",
|
||||
sa.Column("id", sa.Integer(), nullable=False),
|
||||
sa.Column("name", sa.String(length=128), nullable=True),
|
||||
sa.Column("user_id", sa.Integer(), nullable=False),
|
||||
sa.Column("ttl", sa.BigInteger(), nullable=False),
|
||||
sa.Column("issued_at", sa.BigInteger(), nullable=False),
|
||||
sa.Column("revoked", sa.Boolean(), nullable=False),
|
||||
sa.ForeignKeyConstraint(["user_id"], ["users.id"]),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_table('api_keys')
|
||||
op.drop_table("api_keys")
|
||||
|
@ -5,15 +5,15 @@ Create Date: 2018-10-11 09:44:57.099854
|
||||
|
||||
"""
|
||||
|
||||
revision = 'c87cb989af04'
|
||||
down_revision = '9392b9f9a805'
|
||||
revision = "c87cb989af04"
|
||||
down_revision = "9392b9f9a805"
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.create_index(op.f('ix_domains_name'), 'domains', ['name'], unique=False)
|
||||
op.create_index(op.f("ix_domains_name"), "domains", ["name"], unique=False)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_index(op.f('ix_domains_name'), table_name='domains')
|
||||
op.drop_index(op.f("ix_domains_name"), table_name="domains")
|
||||
|
@ -7,8 +7,8 @@ Create Date: 2018-02-23 11:00:02.150561
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'ce547319f7be'
|
||||
down_revision = '5bc47fa7cac4'
|
||||
revision = "ce547319f7be"
|
||||
down_revision = "5bc47fa7cac4"
|
||||
|
||||
import sqlalchemy as sa
|
||||
|
||||
@ -24,12 +24,12 @@ TABLE = "certificate_notification_associations"
|
||||
def upgrade():
|
||||
print("Adding id column")
|
||||
op.add_column(
|
||||
TABLE,
|
||||
sa.Column('id', sa.Integer, primary_key=True, autoincrement=True)
|
||||
TABLE, sa.Column("id", sa.Integer, primary_key=True, autoincrement=True)
|
||||
)
|
||||
db.session.commit()
|
||||
db.session.flush()
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_column(TABLE, "id")
|
||||
db.session.commit()
|
||||
|
@ -7,29 +7,36 @@ Create Date: 2016-11-28 13:15:46.995219
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'e3691fc396e9'
|
||||
down_revision = '932525b82f1a'
|
||||
revision = "e3691fc396e9"
|
||||
down_revision = "932525b82f1a"
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
import sqlalchemy_utils
|
||||
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('logs',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('certificate_id', sa.Integer(), nullable=True),
|
||||
sa.Column('log_type', sa.Enum('key_view', name='log_type'), nullable=False),
|
||||
sa.Column('logged_at', sqlalchemy_utils.types.arrow.ArrowType(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('user_id', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['certificate_id'], ['certificates.id'], ),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
op.create_table(
|
||||
"logs",
|
||||
sa.Column("id", sa.Integer(), nullable=False),
|
||||
sa.Column("certificate_id", sa.Integer(), nullable=True),
|
||||
sa.Column("log_type", sa.Enum("key_view", name="log_type"), nullable=False),
|
||||
sa.Column(
|
||||
"logged_at",
|
||||
sqlalchemy_utils.types.arrow.ArrowType(),
|
||||
server_default=sa.text("now()"),
|
||||
nullable=False,
|
||||
),
|
||||
sa.Column("user_id", sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(["certificate_id"], ["certificates.id"]),
|
||||
sa.ForeignKeyConstraint(["user_id"], ["users.id"]),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('logs')
|
||||
op.drop_table("logs")
|
||||
### end Alembic commands ###
|
||||
|
@ -7,25 +7,44 @@ Create Date: 2018-11-05 09:49:40.226368
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'ee827d1e1974'
|
||||
down_revision = '7ead443ba911'
|
||||
revision = "ee827d1e1974"
|
||||
down_revision = "7ead443ba911"
|
||||
|
||||
from alembic import op
|
||||
from sqlalchemy.exc import ProgrammingError
|
||||
|
||||
|
||||
def upgrade():
|
||||
connection = op.get_bind()
|
||||
connection.execute("CREATE EXTENSION IF NOT EXISTS pg_trgm")
|
||||
|
||||
op.create_index('ix_certificates_cn', 'certificates', ['cn'], unique=False, postgresql_ops={'cn': 'gin_trgm_ops'},
|
||||
postgresql_using='gin')
|
||||
op.create_index('ix_certificates_name', 'certificates', ['name'], unique=False,
|
||||
postgresql_ops={'name': 'gin_trgm_ops'}, postgresql_using='gin')
|
||||
op.create_index('ix_domains_name_gin', 'domains', ['name'], unique=False, postgresql_ops={'name': 'gin_trgm_ops'},
|
||||
postgresql_using='gin')
|
||||
op.create_index(
|
||||
"ix_certificates_cn",
|
||||
"certificates",
|
||||
["cn"],
|
||||
unique=False,
|
||||
postgresql_ops={"cn": "gin_trgm_ops"},
|
||||
postgresql_using="gin",
|
||||
)
|
||||
op.create_index(
|
||||
"ix_certificates_name",
|
||||
"certificates",
|
||||
["name"],
|
||||
unique=False,
|
||||
postgresql_ops={"name": "gin_trgm_ops"},
|
||||
postgresql_using="gin",
|
||||
)
|
||||
op.create_index(
|
||||
"ix_domains_name_gin",
|
||||
"domains",
|
||||
["name"],
|
||||
unique=False,
|
||||
postgresql_ops={"name": "gin_trgm_ops"},
|
||||
postgresql_using="gin",
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_index('ix_domains_name', table_name='domains')
|
||||
op.drop_index('ix_certificates_name', table_name='certificates')
|
||||
op.drop_index('ix_certificates_cn', table_name='certificates')
|
||||
op.drop_index("ix_domains_name", table_name="domains")
|
||||
op.drop_index("ix_certificates_name", table_name="certificates")
|
||||
op.drop_index("ix_certificates_cn", table_name="certificates")
|
||||
|
@ -7,17 +7,22 @@ Create Date: 2018-10-11 11:23:31.195471
|
||||
|
||||
"""
|
||||
|
||||
revision = 'f2383bf08fbc'
|
||||
down_revision = 'c87cb989af04'
|
||||
revision = "f2383bf08fbc"
|
||||
down_revision = "c87cb989af04"
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.create_index('ix_certificates_id_desc', 'certificates', [sa.text('id DESC')], unique=True,
|
||||
postgresql_using='btree')
|
||||
op.create_index(
|
||||
"ix_certificates_id_desc",
|
||||
"certificates",
|
||||
[sa.text("id DESC")],
|
||||
unique=True,
|
||||
postgresql_using="btree",
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_index('ix_certificates_id_desc', table_name='certificates')
|
||||
op.drop_index("ix_certificates_id_desc", table_name="certificates")
|
||||
|
Reference in New Issue
Block a user