diff options
author | christian.simms <unknown> | 2008-04-06 20:58:37 +0000 |
---|---|---|
committer | christian.simms <unknown> | 2008-04-06 20:58:37 +0000 |
commit | 8af121c421f45a108894f56c8f713ae455410020 (patch) | |
tree | 0fef911c6c38f1fb8f149bb1848e0b5ecadcbf85 /migrate/versioning/script | |
parent | c13931b6b911dde2b3732c23428da7be64786a9e (diff) | |
download | sqalchemy-migrate-8af121c421f45a108894f56c8f713ae455410020.tar.gz |
Change make_update_script_for_model shell command to compare two versions of Python model (issue #12); add shell test for new diff'ing apis
Diffstat (limited to 'migrate/versioning/script')
-rw-r--r-- | migrate/versioning/script/py.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/migrate/versioning/script/py.py b/migrate/versioning/script/py.py index 7add4f4..1f2685a 100644 --- a/migrate/versioning/script/py.py +++ b/migrate/versioning/script/py.py @@ -20,16 +20,17 @@ class PythonScript(base.BaseScript): shutil.copy(src,path) @classmethod - def make_update_script_for_model(cls,path,engine,model,repository,**opts): + def make_update_script_for_model(cls,engine,oldmodel,model,repository,**opts): """Create a migration script""" - cls.require_notfound(path) + #cls.require_notfound(path) # TODO: yank? # Compute differences. if isinstance(repository, basestring): from migrate.versioning.repository import Repository # oh dear, an import cycle! repository=Repository(repository) + oldmodel = loadModel(oldmodel) model = loadModel(model) - diff = schemadiff.getDiffOfModelAgainstDatabase(model, engine, excludeTables=[repository.version_table]) + diff = schemadiff.getDiffOfModelAgainstModel(oldmodel, model, engine, excludeTables=[repository.version_table]) upgradeDecls, upgradeCommands = genmodel.ModelGenerator(diff).toUpgradePython() #downgradeCommands = genmodel.ModelGenerator(diff).toDowngradePython() @@ -43,7 +44,7 @@ class PythonScript(base.BaseScript): contents = contents.replace(search, upgradeDecls + '\n\n' + search, 1) if upgradeCommands: contents = contents.replace(' pass', upgradeCommands, 1) #if downgradeCommands: contents = contents.replace(' pass', downgradeCommands, 1) # TODO - open(path, 'w').write(contents) + return contents # TODO: reinstate? open(path, 'w').write(contents) @classmethod def verify_module(cls,path): |