1
0
Fork 0

- database versioning with migrate

- backend for domains
- settings for immutable things and config encapsulation


git-svn-id: file:///home/www/usr01/svn/gnuviechadmin/gnuviech.info/gnuviechadmin/trunk@229 a67ec6bc-e5d5-0310-a910-815c51eb3124
This commit is contained in:
Jan Dittberner 2007-07-05 09:00:34 +00:00
parent 0d12afc71e
commit 3f4457bdca
22 changed files with 432 additions and 50 deletions

4
data/dbrepo/README Normal file
View file

@ -0,0 +1,4 @@
This is a database migration repository.
More information at
http://trac.erosson.com/migrate

0
data/dbrepo/__init__.py Normal file
View file

4
data/dbrepo/manage.py Normal file
View file

@ -0,0 +1,4 @@
#!/usr/bin/python
from migrate.versioning.shell import main
main(repository='data/dbrepo')

20
data/dbrepo/migrate.cfg Normal file
View file

@ -0,0 +1,20 @@
[db_settings]
# Used to identify which repository this database is versioned under.
# You can use the name of your project.
repository_id=Gnuviechadmin Schema Repository
# The name of the database table used to track the schema version.
# This name shouldn't already be used by your project.
# If this is changed once a database is under version control, you'll need to
# change the table name in each database too.
version_table=migrate_version
# When committing a change script, Migrate will attempt to generate the
# sql for all supported databases; normally, if one of them fails - probably
# because you don't have that database installed - it is ignored and the
# commit continues, perhaps ending successfully.
# Databases in this list MUST compile successfully during a commit, or the
# entire commit will fail. List the databases your application will actually
# be using to ensure your updates to that database work properly.
# This must be a list; example: ['postgres','sqlite']
required_dbs=[]

View file

@ -0,0 +1 @@
DROP SCHEMA gva;

View file

@ -0,0 +1 @@
CREATE SCHEMA gva;

View file

@ -0,0 +1,84 @@
from sqlalchemy import *
from migrate import *
from gnuviechadmin.backend.settings import dbschema
meta = BoundMetaData(migrate_engine)
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),
schema = dbschema
)
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)),
Column('clientid', Integer, ForeignKey("client.clientid"),
nullable=False),
Column('sysuid', Integer, nullable=False, unique=True),
Column('lastchange', DateTime, default=func.now()),
schema = dbschema
)
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),
Column('sysuserid', Integer, ForeignKey("sysuser.sysuserid"),
nullable=False),
schema = dbschema
)
record = Table(
'record', meta,
Column('recordid', Integer, primary_key=True),
Column('domainid', Integer, ForeignKey("domain.domainid"),
nullable=False),
Column('name', String(255)),
Column('type', String(6)),
Column('content', String(255)),
Column('ttl', Integer),
Column('prio', Integer),
Column('change_date', Integer),
schema = dbschema
)
supermaster = Table(
'supermaster', meta,
Column('ip', String(25), nullable=False),
Column('nameserver', String(255), nullable=False),
Column('account', Integer, ForeignKey("sysuser.sysuserid"),
nullable=False),
schema = dbschema
)
def upgrade():
client.create()
sysuser.create()
domain.create()
record.create()
supermaster.create()
def downgrade():
supermaster.drop()
record.drop()
domain.drop()
sysuser.drop()
client.drop()

View file