mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2024-11-09 23:20:27 +00:00
143 lines
5.9 KiB
Python
143 lines
5.9 KiB
Python
|
"""Init DB
|
||
|
|
||
|
Revision ID: 787bdba9e147
|
||
|
Revises:
|
||
|
Create Date: 2018-06-22 09:45:58.941559
|
||
|
|
||
|
"""
|
||
|
from alembic import op
|
||
|
import sqlalchemy as sa
|
||
|
|
||
|
|
||
|
# revision identifiers, used by Alembic.
|
||
|
revision = '787bdba9e147'
|
||
|
down_revision = None
|
||
|
branch_labels = None
|
||
|
depends_on = None
|
||
|
|
||
|
|
||
|
def upgrade():
|
||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||
|
op.create_table('account',
|
||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||
|
sa.Column('name', sa.String(length=40), nullable=False),
|
||
|
sa.Column('description', sa.String(length=128), nullable=True),
|
||
|
sa.Column('contact', sa.String(length=128), nullable=True),
|
||
|
sa.Column('mail', sa.String(length=128), nullable=True),
|
||
|
sa.PrimaryKeyConstraint('id')
|
||
|
)
|
||
|
op.create_index(op.f('ix_account_name'), 'account', ['name'], unique=True)
|
||
|
op.create_table('domain_template',
|
||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||
|
sa.Column('name', sa.String(length=255), nullable=True),
|
||
|
sa.Column('description', sa.String(length=255), nullable=True),
|
||
|
sa.PrimaryKeyConstraint('id')
|
||
|
)
|
||
|
op.create_index(op.f('ix_domain_template_name'), 'domain_template', ['name'], unique=True)
|
||
|
op.create_table('history',
|
||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||
|
sa.Column('msg', sa.String(length=256), nullable=True),
|
||
|
sa.Column('detail', sa.Text(), nullable=True),
|
||
|
sa.Column('created_by', sa.String(length=128), nullable=True),
|
||
|
sa.Column('created_on', sa.DateTime(), nullable=True),
|
||
|
sa.PrimaryKeyConstraint('id')
|
||
|
)
|
||
|
op.create_table('role',
|
||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||
|
sa.Column('name', sa.String(length=64), nullable=True),
|
||
|
sa.Column('description', sa.String(length=128), nullable=True),
|
||
|
sa.PrimaryKeyConstraint('id')
|
||
|
)
|
||
|
op.create_index(op.f('ix_role_name'), 'role', ['name'], unique=True)
|
||
|
op.create_table('setting',
|
||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||
|
sa.Column('name', sa.String(length=64), nullable=True),
|
||
|
sa.Column('value', sa.String(length=256), nullable=True),
|
||
|
sa.PrimaryKeyConstraint('id')
|
||
|
)
|
||
|
op.create_table('domain',
|
||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||
|
sa.Column('name', sa.String(length=255), nullable=True),
|
||
|
sa.Column('master', sa.String(length=128), nullable=True),
|
||
|
sa.Column('type', sa.String(length=6), nullable=False),
|
||
|
sa.Column('serial', sa.Integer(), nullable=True),
|
||
|
sa.Column('notified_serial', sa.Integer(), nullable=True),
|
||
|
sa.Column('last_check', sa.Integer(), nullable=True),
|
||
|
sa.Column('dnssec', sa.Integer(), nullable=True),
|
||
|
sa.Column('account_id', sa.Integer(), nullable=True),
|
||
|
sa.ForeignKeyConstraint(['account_id'], ['account.id'], ),
|
||
|
sa.PrimaryKeyConstraint('id')
|
||
|
)
|
||
|
op.create_index(op.f('ix_domain_name'), 'domain', ['name'], unique=True)
|
||
|
op.create_table('domain_template_record',
|
||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||
|
sa.Column('name', sa.String(length=255), nullable=True),
|
||
|
sa.Column('type', sa.String(length=64), nullable=True),
|
||
|
sa.Column('ttl', sa.Integer(), nullable=True),
|
||
|
sa.Column('data', sa.Text(), nullable=True),
|
||
|
sa.Column('status', sa.Boolean(), nullable=True),
|
||
|
sa.Column('template_id', sa.Integer(), nullable=True),
|
||
|
sa.ForeignKeyConstraint(['template_id'], ['domain_template.id'], ),
|
||
|
sa.PrimaryKeyConstraint('id')
|
||
|
)
|
||
|
op.create_table('user',
|
||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||
|
sa.Column('username', sa.String(length=64), nullable=True),
|
||
|
sa.Column('password', sa.String(length=64), nullable=True),
|
||
|
sa.Column('firstname', sa.String(length=64), nullable=True),
|
||
|
sa.Column('lastname', sa.String(length=64), nullable=True),
|
||
|
sa.Column('email', sa.String(length=128), nullable=True),
|
||
|
sa.Column('avatar', sa.String(length=128), nullable=True),
|
||
|
sa.Column('otp_secret', sa.String(length=16), nullable=True),
|
||
|
sa.Column('role_id', sa.Integer(), nullable=True),
|
||
|
sa.ForeignKeyConstraint(['role_id'], ['role.id'], ),
|
||
|
sa.PrimaryKeyConstraint('id')
|
||
|
)
|
||
|
op.create_index(op.f('ix_user_username'), 'user', ['username'], unique=True)
|
||
|
op.create_table('account_user',
|
||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||
|
sa.Column('account_id', sa.Integer(), nullable=False),
|
||
|
sa.Column('user_id', sa.Integer(), nullable=False),
|
||
|
sa.ForeignKeyConstraint(['account_id'], ['account.id'], ),
|
||
|
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
|
||
|
sa.PrimaryKeyConstraint('id')
|
||
|
)
|
||
|
op.create_table('domain_setting',
|
||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||
|
sa.Column('domain_id', sa.Integer(), nullable=True),
|
||
|
sa.Column('setting', sa.String(length=255), nullable=False),
|
||
|
sa.Column('value', sa.String(length=255), nullable=True),
|
||
|
sa.ForeignKeyConstraint(['domain_id'], ['domain.id'], ),
|
||
|
sa.PrimaryKeyConstraint('id')
|
||
|
)
|
||
|
op.create_table('domain_user',
|
||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||
|
sa.Column('domain_id', sa.Integer(), nullable=False),
|
||
|
sa.Column('user_id', sa.Integer(), nullable=False),
|
||
|
sa.ForeignKeyConstraint(['domain_id'], ['domain.id'], ),
|
||
|
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
|
||
|
sa.PrimaryKeyConstraint('id')
|
||
|
)
|
||
|
# ### end Alembic commands ###
|
||
|
|
||
|
|
||
|
def downgrade():
|
||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||
|
op.drop_table('domain_user')
|
||
|
op.drop_table('domain_setting')
|
||
|
op.drop_table('account_user')
|
||
|
op.drop_index(op.f('ix_user_username'), table_name='user')
|
||
|
op.drop_table('user')
|
||
|
op.drop_table('domain_template_record')
|
||
|
op.drop_index(op.f('ix_domain_name'), table_name='domain')
|
||
|
op.drop_table('domain')
|
||
|
op.drop_table('setting')
|
||
|
op.drop_index(op.f('ix_role_name'), table_name='role')
|
||
|
op.drop_table('role')
|
||
|
op.drop_table('history')
|
||
|
op.drop_index(op.f('ix_domain_template_name'), table_name='domain_template')
|
||
|
op.drop_table('domain_template')
|
||
|
op.drop_index(op.f('ix_account_name'), table_name='account')
|
||
|
op.drop_table('account')
|
||
|
# ### end Alembic commands ###
|