2007-07-05 11:00:34 +02:00
|
|
|
from sqlalchemy import *
|
|
|
|
from migrate import *
|
|
|
|
from gnuviechadmin.backend.settings import dbschema
|
|
|
|
|
2008-04-04 20:36:46 +02:00
|
|
|
meta = MetaData(migrate_engine)
|
2007-07-05 11:00:34 +02:00
|
|
|
client = Table(
|
|
|
|
'client', meta,
|
|
|
|
Column('clientid', Integer, primary_key=True),
|
|
|
|
Column('title', String(10)),
|
|
|
|
Column('firstname', String(64), nullable=False),
|
|
|
|
Column('lastname', String(64), nullable=False),
|
|
|
|
Column('address1', String(64), nullable=False),
|
|
|
|
Column('address2', String(64)),
|
|
|
|
Column('zip', String(7), nullable=False),
|
|
|
|
Column('city', String(64), nullable=False),
|
|
|
|
Column('country', String(5), nullable=False),
|
|
|
|
Column('phone', String(32), nullable=False),
|
|
|
|
Column('mobile', String(32)),
|
|
|
|
Column('fax', String(32)),
|
|
|
|
Column('email', String(64), unique=True, nullable=False),
|
2008-06-06 21:20:18 +02:00
|
|
|
schema = dbschema)
|
2007-07-05 11:00:34 +02:00
|
|
|
sysuser = Table(
|
|
|
|
'sysuser', meta,
|
|
|
|
Column('sysuserid', Integer, primary_key=True),
|
|
|
|
Column('username', String(12), nullable=False, unique=True),
|
|
|
|
Column('usertype', Integer, nullable=False, default=0, index=True),
|
|
|
|
Column('home', String(128)),
|
|
|
|
Column('shell', Boolean, nullable=False, default=False),
|
|
|
|
Column('clearpass', String(64)),
|
|
|
|
Column('md5pass', String(34)),
|
2008-04-04 20:36:46 +02:00
|
|
|
Column('clientid', Integer, ForeignKey(client.c.clientid),
|
2007-07-05 11:00:34 +02:00
|
|
|
nullable=False),
|
|
|
|
Column('sysuid', Integer, nullable=False, unique=True),
|
|
|
|
Column('lastchange', DateTime, default=func.now()),
|
2008-06-06 21:20:18 +02:00
|
|
|
schema = dbschema)
|
2007-07-05 11:00:34 +02:00
|
|
|
domain = Table(
|
|
|
|
'domain', meta,
|
|
|
|
Column('domainid', Integer, primary_key=True),
|
|
|
|
Column('name', String(255), nullable=False, unique=True),
|
|
|
|
Column('master', String(20)),
|
|
|
|
Column('last_check', Integer),
|
|
|
|
Column('type', String(6), nullable=False),
|
|
|
|
Column('notified_serial', Integer),
|
2008-04-04 20:36:46 +02:00
|
|
|
Column('sysuserid', Integer, ForeignKey(sysuser.c.sysuserid),
|
2007-07-05 11:00:34 +02:00
|
|
|
nullable=False),
|
2008-06-06 21:20:18 +02:00
|
|
|
schema = dbschema)
|
2007-07-05 11:00:34 +02:00
|
|
|
record = Table(
|
|
|
|
'record', meta,
|
|
|
|
Column('recordid', Integer, primary_key=True),
|
2008-04-04 20:36:46 +02:00
|
|
|
Column('domainid', Integer, ForeignKey(domain.c.domainid),
|
2007-07-05 11:00:34 +02:00
|
|
|
nullable=False),
|
|
|
|
Column('name', String(255)),
|
|
|
|
Column('type', String(6)),
|
|
|
|
Column('content', String(255)),
|
|
|
|
Column('ttl', Integer),
|
|
|
|
Column('prio', Integer),
|
|
|
|
Column('change_date', Integer),
|
2008-06-06 21:20:18 +02:00
|
|
|
schema = dbschema)
|
2007-07-05 11:00:34 +02:00
|
|
|
supermaster = Table(
|
|
|
|
'supermaster', meta,
|
|
|
|
Column('ip', String(25), nullable=False),
|
|
|
|
Column('nameserver', String(255), nullable=False),
|
2008-04-04 20:36:46 +02:00
|
|
|
Column('account', Integer, ForeignKey(sysuser.c.sysuserid),
|
2007-07-05 11:00:34 +02:00
|
|
|
nullable=False),
|
2008-06-06 21:20:18 +02:00
|
|
|
schema = dbschema)
|
|
|
|
|
2007-07-05 11:00:34 +02:00
|
|
|
|
|
|
|
def upgrade():
|
|
|
|
client.create()
|
|
|
|
sysuser.create()
|
|
|
|
domain.create()
|
|
|
|
record.create()
|
|
|
|
supermaster.create()
|
|
|
|
|
2008-06-06 21:20:18 +02:00
|
|
|
|
2007-07-05 11:00:34 +02:00
|
|
|
def downgrade():
|
|
|
|
supermaster.drop()
|
|
|
|
record.drop()
|
|
|
|
domain.drop()
|
|
|
|
sysuser.drop()
|
|
|
|
client.drop()
|