Jan Dittberner
222b35b033
* upgrade migrate repository structure (fixes #32, #27) * switch to PasteDeploy (fixes #31) * update for SQLAlchemy 0.5 compatibility * add python-gnutls dependency (addresses #35)
48 lines
1.6 KiB
Python
48 lines
1.6 KiB
Python
from sqlalchemy import *
|
|
from migrate import *
|
|
from gnuviechadmin.backend.settings import dbschema
|
|
|
|
meta = MetaData(migrate_engine)
|
|
domain = Table('domain', meta, schema = dbschema, autoload = True)
|
|
mailaccount = Table(
|
|
'mailaccount', meta,
|
|
Column('mailaccountid', Integer, primary_key = True),
|
|
Column('domainid', Integer, ForeignKey(domain.c.domainid),
|
|
nullable = False),
|
|
Column('mailaccount', String(12), nullable = False, unique = True),
|
|
Column('clearpass', String(64)),
|
|
Column('cryptpass', String(34)),
|
|
Column('uid', Integer, nullable = False),
|
|
Column('gid', Integer, nullable = False),
|
|
Column('home', String(128), nullable = False),
|
|
Column('spamcheck', Boolean, nullable = False, default = False),
|
|
Column('sajunkscore', Integer),
|
|
schema = dbschema)
|
|
mailaddress = Table(
|
|
'mailaddress', meta,
|
|
Column('mailaddressid', Integer, primary_key = True),
|
|
Column('domainid', Integer, ForeignKey(domain.c.domainid),
|
|
nullable = False),
|
|
Column('email', String(255), nullable = False),
|
|
UniqueConstraint('email', 'domainid'),
|
|
schema = dbschema)
|
|
mailtarget = Table(
|
|
'mailtarget', meta,
|
|
Column('mailtargetid', Integer, primary_key = True),
|
|
Column('mailaddressid', Integer, ForeignKey(mailaddress.c.mailaddressid),
|
|
nullable = False),
|
|
Column('target', String(128), nullable = False),
|
|
UniqueConstraint('target', 'mailaddressid'),
|
|
schema = dbschema)
|
|
|
|
|
|
def upgrade():
|
|
mailaccount.create()
|
|
mailaddress.create()
|
|
mailtarget.create()
|
|
|
|
|
|
def downgrade():
|
|
mailtarget.drop()
|
|
mailaddress.drop()
|
|
mailaccount.drop()
|