]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
add a stamp command
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 19 Apr 2011 18:10:52 +0000 (14:10 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 19 Apr 2011 18:10:52 +0000 (14:10 -0400)
alembic/command.py

index f1d5000634ab4f1106ebcffca5222954e18f4f0f..db7301680a3f8dbe34c2c8eab3694c62e690e3bd 100644 (file)
@@ -120,6 +120,25 @@ def current(config):
     )
     script.run_env()
 
+def stamp(config, revision, sql=False):
+    """'stamp' the revision table with the given revision; don't
+    run any migrations."""
+
+    script = ScriptDirectory.from_config(config)
+    def do_stamp(rev):
+        current = context.get_context()._current_rev()
+        dest = script._get_rev(revision)
+        if dest is not None:
+            dest = dest.revision
+        context.get_context()._update_current_rev(current, dest)
+        return []
+    context.opts(
+        config, 
+        fn = do_stamp,
+        as_sql = sql,
+    )
+    script.run_env()
+
 def splice(config, parent, child):
     """'splice' two branches, creating a new revision file."""