46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
|
from sqlalchemy import *
|
||
|
from migrate import *
|
||
|
|
||
|
meta = BoundMetaData(migrate_engine)
|
||
|
supermasters = Table('supermasters', meta,
|
||
|
Column('ip', String(25), nullable=False),
|
||
|
Column('nameserver', String(255), nullable=False),
|
||
|
Column('account', String(40)),
|
||
|
)
|
||
|
domains = Table('domains', meta,
|
||
|
Column('id', Integer, primary_key=True),
|
||
|
Column('name', String(255), nullable=False),
|
||
|
Column('master', String(20)),
|
||
|
Column('last_check', Integer),
|
||
|
Column('type', String(6), nullable=False),
|
||
|
Column('notified_serial', Integer),
|
||
|
Column('account', String(40)),
|
||
|
UniqueConstraint('name', name='name_index')
|
||
|
)
|
||
|
|
||
|
records = Table('records', meta,
|
||
|
Column('id', Integer, primary_key=True),
|
||
|
Column('domain_id', Integer),
|
||
|
Column('name', String(255)),
|
||
|
Column('type', String(6)),
|
||
|
Column('content', String(255)),
|
||
|
Column('ttl', Integer),
|
||
|
Column('prio', Integer),
|
||
|
Column('change_date', Integer),
|
||
|
ForeignKeyConstraint(['domain_id'], ['domains.id'],
|
||
|
ondelete='CASCADE', name='domain_exists')
|
||
|
)
|
||
|
Index('domain_id', records.c.domain_id)
|
||
|
Index('nametype_index', records.c.name, records.c.type)
|
||
|
Index('rec_name_index', records.c.name)
|
||
|
|
||
|
def upgrade():
|
||
|
supermasters.create()
|
||
|
domains.create()
|
||
|
records.create()
|
||
|
|
||
|
def downgrade():
|
||
|
records.drop()
|
||
|
domains.drop()
|
||
|
supermasters.drop()
|