- OR-Mapping test with SQLAlchemy and migrate
git-svn-id: file:///home/www/usr01/svn/gnuviechadmin/gnuviech.info/gnuviechadmin/trunk@203 a67ec6bc-e5d5-0310-a910-815c51eb3124
This commit is contained in:
parent
bf7992a600
commit
4d6fb63343
11 changed files with 427 additions and 0 deletions
4
backend/gnuviechadmin/ormaptest_repo/README
Normal file
4
backend/gnuviechadmin/ormaptest_repo/README
Normal file
|
@ -0,0 +1,4 @@
|
|||
This is a database migration repository.
|
||||
|
||||
More information at
|
||||
http://trac.erosson.com/migrate
|
0
backend/gnuviechadmin/ormaptest_repo/__init__.py
Normal file
0
backend/gnuviechadmin/ormaptest_repo/__init__.py
Normal file
4
backend/gnuviechadmin/ormaptest_repo/manage.py
Normal file
4
backend/gnuviechadmin/ormaptest_repo/manage.py
Normal file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/python
|
||||
from migrate.versioning.shell import main
|
||||
|
||||
main(repository='ormaptest_repo')
|
20
backend/gnuviechadmin/ormaptest_repo/migrate.cfg
Normal file
20
backend/gnuviechadmin/ormaptest_repo/migrate.cfg
Normal 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=OR Mapping Test
|
||||
|
||||
# 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=[]
|
14
backend/gnuviechadmin/ormaptest_repo/versions/1/1.py
Normal file
14
backend/gnuviechadmin/ormaptest_repo/versions/1/1.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
from sqlalchemy import *
|
||||
from migrate import *
|
||||
|
||||
meta = BoundMetaData(migrate_engine)
|
||||
account = Table('account', meta,
|
||||
Column('id', Integer, primary_key=True),
|
||||
Column('login', String(40)),
|
||||
Column('passwd', String(40)))
|
||||
|
||||
def upgrade():
|
||||
account.create()
|
||||
|
||||
def downgrade():
|
||||
account.drop()
|
11
backend/gnuviechadmin/ormaptest_repo/versions/2/2.py
Normal file
11
backend/gnuviechadmin/ormaptest_repo/versions/2/2.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
from sqlalchemy import *
|
||||
from migrate import *
|
||||
|
||||
meta = BoundMetaData(migrate_engine)
|
||||
account = Table('account', meta)
|
||||
|
||||
def upgrade():
|
||||
account.drop()
|
||||
|
||||
def downgrade():
|
||||
account.create()
|
45
backend/gnuviechadmin/ormaptest_repo/versions/3/3.py
Normal file
45
backend/gnuviechadmin/ormaptest_repo/versions/3/3.py
Normal file
|
@ -0,0 +1,45 @@
|
|||
from sqlalchemy import *
|
||||
from migrate import *
|
||||
|
||||
meta = BoundMetaData(migrate_engine)
|
||||
supermasters = Table('supermasters', meta,
|
||||
Column('ip', String(25), nullable=False),
|
||||
Column('nameserver', String(255), nullable=False),
|
||||
Column('account', String(40)),
|
||||
)
|
||||
domains = Table('domains', meta,
|
||||
Column('id', Integer, primary_key=True),
|
||||
Column('name', String(255), nullable=False),
|
||||
Column('master', String(20)),
|
||||
Column('last_check', Integer),
|
||||
Column('type', String(6), nullable=False),
|
||||
Column('notified_serial', Integer),
|
||||
Column('account', String(40)),
|
||||
UniqueConstraint('name', name='name_index')
|
||||
)
|
||||
|
||||
records = Table('records', meta,
|
||||
Column('id', Integer, primary_key=True),
|
||||
Column('domain_id', Integer),
|
||||
Column('name', String(255)),
|
||||
Column('type', String(6)),
|
||||
Column('content', String(255)),
|
||||
Column('ttl', Integer),
|
||||
Column('prio', Integer),
|
||||
Column('change_date', Integer),
|
||||
ForeignKeyConstraint(['domain_id'], ['domains.id'],
|
||||
ondelete='CASCADE', name='domain_exists')
|
||||
)
|
||||
Index('domain_id', records.c.domain_id)
|
||||
Index('nametype_index', records.c.name, records.c.type)
|
||||
Index('rec_name_index', records.c.name)
|
||||
|
||||
def upgrade():
|
||||
supermasters.create()
|
||||
domains.create()
|
||||
records.create()
|
||||
|
||||
def downgrade():
|
||||
records.drop()
|
||||
domains.drop()
|
||||
supermasters.drop()
|
Loading…
Add table
Add a link
Reference in a new issue