adding sql_script template customizations, removing unneeded imports, updating docs

This commit is contained in:
iElectric 2009-08-12 00:06:36 +02:00
parent ccf7be3372
commit c8d48124f6
6 changed files with 9 additions and 3 deletions

View File

@ -3,7 +3,7 @@
- added option to define custom templates through option ``--templates_path`` and ``--templates_theme``, read more in :ref:`tutorial section <custom-templates>` - added option to define custom templates through option ``--templates_path`` and ``--templates_theme``, read more in :ref:`tutorial section <custom-templates>`
- use Python logging for output, can be shut down by passing ``--disable_logging`` to :func:`migrate.versioning.shell.main` - use Python logging for output, can be shut down by passing ``--disable_logging`` to :func:`migrate.versioning.shell.main`
- `url` parameter can also be an :class:`Engine` instance (this usage is discouraged though sometimes necessary) - `url` parameter can also be an :class:`Engine` instance (this usage is discouraged though sometimes necessary)
- added support for SQLAlchemy 0.6 (missing oracle and firebird) by Michael Bayer - added support for SQLAlchemy 0.6 by Michael Bayer
- alter, create, drop column / rename table / rename index constructs now accept `alter_metadata` parameter. If True, it will modify Column/Table objects according to changes. Otherwise, everything will be untouched. - alter, create, drop column / rename table / rename index constructs now accept `alter_metadata` parameter. If True, it will modify Column/Table objects according to changes. Otherwise, everything will be untouched.
- complete refactoring of :class:`~migrate.changeset.schema.ColumnDelta` (fixes issue 23) - complete refactoring of :class:`~migrate.changeset.schema.ColumnDelta` (fixes issue 23)
- added support for :ref:`firebird <firebird-d>` - added support for :ref:`firebird <firebird-d>`

View File

@ -9,7 +9,7 @@ import logging
from pkg_resources import resource_filename from pkg_resources import resource_filename
from tempita import Template as TempitaTemplate from tempita import Template as TempitaTemplate
from migrate.versioning import exceptions, script, version, pathed, cfgparse from migrate.versioning import exceptions, version, pathed, cfgparse
from migrate.versioning.template import Template from migrate.versioning.template import Template
from migrate.versioning.config import * from migrate.versioning.config import *

View File

@ -133,7 +133,7 @@ class TestVersionedRepository(fixture.Pathed):
uniq = list() uniq = list()
# Changesets are iterable # Changesets are iterable
for version, change in changeset: for version, change in changeset:
self.assert_(isinstance(change, script.BaseScript)) self.assert_(isinstance(change, BaseScript))
# Changes aren't identical # Changes aren't identical
self.assert_(id(change) not in uniq) self.assert_(id(change) not in uniq)
uniq.append(id(change)) uniq.append(id(change))

View File

@ -33,6 +33,8 @@ class TestTemplate(fixture.Pathed):
manage_tmpl_file = os.path.join(new_templates_dir, 'manage/custom.py_tmpl') manage_tmpl_file = os.path.join(new_templates_dir, 'manage/custom.py_tmpl')
repository_tmpl_file = os.path.join(new_templates_dir, 'repository/custom/README') repository_tmpl_file = os.path.join(new_templates_dir, 'repository/custom/README')
script_tmpl_file = os.path.join(new_templates_dir, 'script/custom.py_tmpl') script_tmpl_file = os.path.join(new_templates_dir, 'script/custom.py_tmpl')
sql_script_tmpl_file = os.path.join(new_templates_dir, 'sql_script/custom.py_tmpl')
MANAGE_CONTENTS = 'print "manage.py"' MANAGE_CONTENTS = 'print "manage.py"'
README_CONTENTS = 'MIGRATE README!' README_CONTENTS = 'MIGRATE README!'
SCRIPT_FILE_CONTENTS = 'print "script.py"' SCRIPT_FILE_CONTENTS = 'print "script.py"'
@ -48,6 +50,7 @@ class TestTemplate(fixture.Pathed):
f = open(manage_tmpl_file, 'w').write(MANAGE_CONTENTS) f = open(manage_tmpl_file, 'w').write(MANAGE_CONTENTS)
f = open(repository_tmpl_file, 'w').write(README_CONTENTS) f = open(repository_tmpl_file, 'w').write(README_CONTENTS)
f = open(script_tmpl_file, 'w').write(SCRIPT_FILE_CONTENTS) f = open(script_tmpl_file, 'w').write(SCRIPT_FILE_CONTENTS)
f = open(sql_script_tmpl_file, 'w').write(SCRIPT_FILE_CONTENTS)
# create repository, manage file and python script # create repository, manage file and python script
kw = {} kw = {}
@ -55,6 +58,7 @@ class TestTemplate(fixture.Pathed):
kw['templates_theme'] = 'custom' kw['templates_theme'] = 'custom'
api.create(new_repo_dest, 'repo_name', **kw) api.create(new_repo_dest, 'repo_name', **kw)
api.script('test', new_repo_dest, **kw) api.script('test', new_repo_dest, **kw)
api.script_sql('postgres', new_repo_dest, **kw)
api.manage(new_manage_dest, **kw) api.manage(new_manage_dest, **kw)
# assert changes # assert changes
@ -62,3 +66,5 @@ class TestTemplate(fixture.Pathed):
self.assertEqual(open(os.path.join(new_repo_dest, 'manage.py')).read(), MANAGE_CONTENTS) self.assertEqual(open(os.path.join(new_repo_dest, 'manage.py')).read(), MANAGE_CONTENTS)
self.assertEqual(open(os.path.join(new_repo_dest, 'README')).read(), README_CONTENTS) self.assertEqual(open(os.path.join(new_repo_dest, 'README')).read(), README_CONTENTS)
self.assertEqual(open(os.path.join(new_repo_dest, 'versions/001_test.py')).read(), SCRIPT_FILE_CONTENTS) self.assertEqual(open(os.path.join(new_repo_dest, 'versions/001_test.py')).read(), SCRIPT_FILE_CONTENTS)
self.assertEqual(open(os.path.join(new_repo_dest, 'versions/002_postgres_downgrade.sql')).read(), SCRIPT_FILE_CONTENTS)
self.assertEqual(open(os.path.join(new_repo_dest, 'versions/002_postgres_upgrade.sql')).read(), SCRIPT_FILE_CONTENTS)