2008-01-12 23:24:08 +01:00
|
|
|
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)),
|
2008-06-06 21:20:18 +02:00
|
|
|
UniqueConstraint('name', name='name_index'))
|
2008-01-12 23:24:08 +01:00
|
|
|
|
|
|
|
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'],
|
2008-06-06 21:20:18 +02:00
|
|
|
ondelete='CASCADE', name='domain_exists'))
|
2008-01-12 23:24:08 +01:00
|
|
|
Index('domain_id', records.c.domain_id)
|
|
|
|
Index('nametype_index', records.c.name, records.c.type)
|
|
|
|
Index('rec_name_index', records.c.name)
|
|
|
|
|
2008-06-06 21:20:18 +02:00
|
|
|
|
2008-01-12 23:24:08 +01:00
|
|
|
def upgrade():
|
|
|
|
supermasters.create()
|
|
|
|
domains.create()
|
|
|
|
records.create()
|
|
|
|
|
2008-06-06 21:20:18 +02:00
|
|
|
|
2008-01-12 23:24:08 +01:00
|
|
|
def downgrade():
|
|
|
|
records.drop()
|
|
|
|
domains.drop()
|
|
|
|
supermasters.drop()
|