mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2025-06-15 12:36:05 +00:00
Merge branch 'PowerDNS-Admin:master' into shine/config_table_key_uniqueness
This commit is contained in:
@ -19,7 +19,7 @@ logger = logging.getLogger('alembic.env')
|
||||
# target_metadata = mymodel.Base.metadata
|
||||
from flask import current_app
|
||||
config.set_main_option('sqlalchemy.url',
|
||||
current_app.config.get('SQLALCHEMY_DATABASE_URI'))
|
||||
current_app.config.get('SQLALCHEMY_DATABASE_URI').replace("%","%%"))
|
||||
target_metadata = current_app.extensions['migrate'].db.metadata
|
||||
|
||||
# other values from the config, defined by the needs of env.py,
|
||||
|
@ -0,0 +1,46 @@
|
||||
"""Fix typo in history detail
|
||||
|
||||
Revision ID: 6ea7dc05f496
|
||||
Revises: fbc7cf864b24
|
||||
Create Date: 2022-05-10 10:16:58.784497
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '6ea7dc05f496'
|
||||
down_revision = 'fbc7cf864b24'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
history_table = sa.sql.table('history',
|
||||
sa.Column('detail', sa.Text),
|
||||
)
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.execute(
|
||||
history_table.update()
|
||||
.where(history_table.c.detail.like('%"add_rrests":%'))
|
||||
.values({
|
||||
'detail': sa.func.replace(
|
||||
sa.func.replace(history_table.c.detail, '"add_rrests":', '"add_rrsets":'),
|
||||
'"del_rrests":', '"del_rrsets":'
|
||||
)
|
||||
})
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.execute(
|
||||
history_table.update()
|
||||
.where(history_table.c.detail.like('%"add_rrsets":%'))
|
||||
.values({
|
||||
'detail': sa.func.replace(
|
||||
sa.func.replace(history_table.c.detail, '"add_rrsets":', '"add_rrests":'),
|
||||
'"del_rrsets":', '"del_rrests":'
|
||||
)
|
||||
})
|
||||
)
|
@ -0,0 +1,31 @@
|
||||
"""update domain type length
|
||||
|
||||
Revision ID: f41520e41cee
|
||||
Revises: 6ea7dc05f496
|
||||
Create Date: 2023-01-10 11:56:28.538485
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'f41520e41cee'
|
||||
down_revision = '6ea7dc05f496'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
with op.batch_alter_table('domain') as batch_op:
|
||||
batch_op.alter_column('type',
|
||||
existing_type=sa.String(length=6),
|
||||
type_=sa.String(length=8))
|
||||
|
||||
|
||||
def downgrade():
|
||||
with op.batch_alter_table('domain') as batch_op:
|
||||
batch_op.alter_column('type',
|
||||
existing_type=sa.String(length=8),
|
||||
type_=sa.String(length=6))
|
||||
|
@ -0,0 +1,47 @@
|
||||
"""update history detail quotes
|
||||
|
||||
Revision ID: fbc7cf864b24
|
||||
Revises: 0967658d9c0d
|
||||
Create Date: 2022-05-04 19:49:54.054285
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'fbc7cf864b24'
|
||||
down_revision = '0967658d9c0d'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
history_table = sa.sql.table(
|
||||
'history',
|
||||
sa.Column('id', sa.Integer),
|
||||
sa.Column('msg', sa.String),
|
||||
sa.Column('detail', sa.Text),
|
||||
sa.Column('created_by', sa.String),
|
||||
sa.Column('created_on', sa.DateTime),
|
||||
sa.Column('domain_id', sa.Integer)
|
||||
)
|
||||
|
||||
op.execute(
|
||||
history_table.update().where(
|
||||
sa.and_(
|
||||
history_table.c.detail.like("%'%"),
|
||||
history_table.c.detail.notlike("%rrests%"),
|
||||
history_table.c.detail.notlike("%rrsets%")
|
||||
)
|
||||
).values({
|
||||
'detail': sa.func.replace(
|
||||
history_table.c.detail,
|
||||
"'",
|
||||
'"'
|
||||
)
|
||||
})
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
pass
|
Reference in New Issue
Block a user