mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2025-06-14 12:06:06 +00:00
Create DB config for pdns and authentication setting
This commit is contained in:
@ -0,0 +1,83 @@
|
||||
"""Add view column to setting table
|
||||
|
||||
Revision ID: 59729e468045
|
||||
Revises: 787bdba9e147
|
||||
Create Date: 2018-08-17 16:17:31.058782
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '59729e468045'
|
||||
down_revision = '787bdba9e147'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def update_data():
|
||||
setting_table = sa.sql.table('setting',
|
||||
sa.sql.column('id', sa.Integer),
|
||||
sa.sql.column('name', sa.String),
|
||||
sa.sql.column('value', sa.String),
|
||||
sa.sql.column('view', sa.String)
|
||||
)
|
||||
|
||||
# just update previous records which have id <= 7
|
||||
op.execute(
|
||||
setting_table.update().where(setting_table.c.id <= 7).values({'view': 'basic'})
|
||||
)
|
||||
|
||||
# add more new settings
|
||||
op.bulk_insert(setting_table,
|
||||
[
|
||||
{'id': 8, 'name': 'pdns_api_url', 'value': '', 'view': 'pdns'},
|
||||
{'id': 9, 'name': 'pdns_api_key', 'value': '', 'view': 'pdns'},
|
||||
{'id': 10, 'name': 'pdns_version', 'value': '4.1.1', 'view': 'pdns'},
|
||||
{'id': 11, 'name': 'local_db_enabled', 'value': 'True', 'view': 'authentication'},
|
||||
{'id': 12, 'name': 'signup_enabled', 'value': 'True', 'view': 'authentication'},
|
||||
{'id': 13, 'name': 'ldap_enabled', 'value': 'False', 'view': 'authentication'},
|
||||
{'id': 14, 'name': 'ldap_type', 'value': 'ldap', 'view': 'authentication'},
|
||||
{'id': 15, 'name': 'ldap_uri', 'value': '', 'view': 'authentication'},
|
||||
{'id': 16, 'name': 'ldap_admin_username', 'value': '', 'view': 'authentication'},
|
||||
{'id': 17, 'name': 'ldap_admin_password', 'value': '', 'view': 'authentication'},
|
||||
{'id': 18, 'name': 'ldap_filter_basic', 'value': '', 'view': 'authentication'},
|
||||
{'id': 19, 'name': 'ldap_filter_username', 'value': '', 'view': 'authentication'},
|
||||
{'id': 20, 'name': 'ldap_sg_enabled', 'value': 'False', 'view': 'authentication'},
|
||||
{'id': 21, 'name': 'ldap_admin_group', 'value': '', 'view': 'authentication'},
|
||||
{'id': 22, 'name': 'ldap_user_group', 'value': '', 'view': 'authentication'},
|
||||
{'id': 23, 'name': 'github_oauth_enabled', 'value': 'False', 'view': 'authentication'},
|
||||
{'id': 24, 'name': 'github_oauth_key', 'value': '', 'view': 'authentication'},
|
||||
{'id': 25, 'name': 'github_oauth_secret', 'value': '', 'view': 'authentication'},
|
||||
{'id': 26, 'name': 'github_oauth_scope', 'value': 'email', 'view': 'authentication'},
|
||||
{'id': 27, 'name': 'github_oauth_api_url', 'value': 'https://api.github.com/user', 'view': 'authentication'},
|
||||
{'id': 28, 'name': 'github_oauth_token_url', 'value': 'https://github.com/login/oauth/access_token', 'view': 'authentication'},
|
||||
{'id': 29, 'name': 'github_oauth_authorize_url', 'value': 'https://github.com/login/oauth/authorize', 'view': 'authentication'},
|
||||
{'id': 30, 'name': 'google_oauth_enabled', 'value': 'False', 'view': 'authentication'},
|
||||
{'id': 31, 'name': 'google_oauth_client_id', 'value': '', 'view': 'authentication'},
|
||||
{'id': 32, 'name': 'google_oauth_client_secret', 'value': '', 'view': 'authentication'},
|
||||
{'id': 33, 'name': 'google_redirect_uri', 'value': '/user/authorized', 'view': 'authentication'},
|
||||
{'id': 34, 'name': 'google_token_url', 'value': 'https://accounts.google.com/o/oauth2/token', 'view': 'authentication'},
|
||||
{'id': 35, 'name': 'google_token_params', 'value': "{'scope': 'email profile'}", 'view': 'authentication'},
|
||||
{'id': 36, 'name': 'google_authorize_url', 'value': 'https://accounts.google.com/o/oauth2/auth', 'view': 'authentication'},
|
||||
{'id': 37, 'name': 'google_base_url', 'value': 'https://www.googleapis.com/oauth2/v1/', 'view': 'authentication'},
|
||||
]
|
||||
)
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('setting', sa.Column('view', sa.String(length=64), nullable=True))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
# update data for new schema
|
||||
update_data()
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('setting', 'view')
|
||||
|
||||
# delete added records in previous version
|
||||
op.execute("DELETE FROM setting WHERE id > 7")
|
||||
# ### end Alembic commands ###
|
Reference in New Issue
Block a user