2008-01-12 21:46:28 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
2007-02-12 22:39:14 +01:00
|
|
|
#
|
2008-01-12 21:46:28 +01:00
|
|
|
# Copyright (C) 2007, 2008 by Jan Dittberner.
|
2007-02-12 22:39:14 +01:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful, but
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
|
|
|
# USA.
|
|
|
|
#
|
|
|
|
# Version: $Id$
|
|
|
|
|
|
|
|
from sqlalchemy import *
|
2008-03-06 20:09:59 +01:00
|
|
|
from sqlalchemy.exceptions import NoSuchTableError
|
2007-07-05 11:00:34 +02:00
|
|
|
import sys
|
|
|
|
import migrate.versioning.api
|
|
|
|
from settings import *
|
2007-02-12 22:39:14 +01:00
|
|
|
|
2007-07-09 08:46:36 +02:00
|
|
|
try:
|
|
|
|
dbversion = migrate.versioning.api.db_version(
|
|
|
|
config.get('database', 'uri'),
|
|
|
|
config.get('database', 'repository'))
|
|
|
|
if dbversion < required_version:
|
|
|
|
print("""Database version is %d but required version is %d, run
|
2007-07-05 11:00:34 +02:00
|
|
|
|
|
|
|
migrate upgrade %s %s
|
|
|
|
|
|
|
|
to fix this.""" %
|
2007-07-09 08:46:36 +02:00
|
|
|
(dbversion, required_version, config.get('database', 'uri'),
|
|
|
|
config.get('database', 'repository')))
|
|
|
|
sys.exit(1)
|
2008-03-06 20:09:59 +01:00
|
|
|
except NoSuchTableError, nste:
|
2007-07-09 08:46:36 +02:00
|
|
|
print nste
|
2007-07-05 11:00:34 +02:00
|
|
|
sys.exit(1)
|
2007-02-13 19:18:09 +01:00
|
|
|
|
|
|
|
meta = BoundMetaData(config.get('database', 'uri'))
|
2007-07-09 08:46:36 +02:00
|
|
|
#meta.engine.echo = True
|
2008-01-12 21:46:28 +01:00
|
|
|
client_table = Table('client', meta, schema = dbschema, autoload = True)
|
|
|
|
sysuser_table = Table('sysuser', meta, schema = dbschema, autoload = True)
|
|
|
|
domain_table = Table('domain', meta, schema = dbschema, autoload = True)
|
|
|
|
record_table = Table('record', meta, schema = dbschema, autoload = True)
|
|
|
|
supermaster_table = Table('supermaster', meta, schema = dbschema,
|
|
|
|
autoload = True)
|
|
|
|
mailaccount_table = Table('mailaccount', meta, schema = dbschema,
|
|
|
|
autoload = True)
|
|
|
|
mailaddress_table = Table('mailaddress', meta, schema = dbschema,
|
|
|
|
autoload = True)
|
|
|
|
mailtarget_table = Table('mailtarget', meta, schema = dbschema,
|
|
|
|
autoload = True)
|