2007-02-12 22:39:14 +01:00
|
|
|
# -*- coding: UTF-8 -*-
|
|
|
|
#
|
|
|
|
# Copyright (C) 2007 by Jan Dittberner.
|
|
|
|
#
|
|
|
|
# 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 *
|
2007-02-13 19:18:09 +01:00
|
|
|
import ConfigParser, os
|
2007-02-12 22:39:14 +01:00
|
|
|
|
2007-02-13 19:18:09 +01:00
|
|
|
config = ConfigParser.ConfigParser()
|
2007-02-28 22:15:20 +01:00
|
|
|
config.readfp(open('gnuviechadmin/defaults.cfg'))
|
|
|
|
config.read(['gnuviechadmin/gva.cfg', os.path.expanduser('~/.gva.cfg')])
|
2007-02-13 19:18:09 +01:00
|
|
|
|
|
|
|
meta = BoundMetaData(config.get('database', 'uri'))
|
2007-02-12 22:39:14 +01:00
|
|
|
client_table = 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))
|
|
|
|
client_table.create(checkfirst=True)
|
|
|
|
|
|
|
|
sysuser_table = 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(32)),
|
|
|
|
Column('clientid', Integer, ForeignKey("client.clientid"), nullable=False),
|
|
|
|
Column('sysuid', Integer, nullable=False, unique=True),
|
|
|
|
Column('lastchange', DateTime, default=func.now())
|
|
|
|
)
|
|
|
|
sysuser_table.create(checkfirst=True)
|