def get_current_revision(self):
"""Return the current revision, usually that which is present
in the ``alembic_version`` table in the database.
If this :class:`.MigrationContext` was configured in "offline"
mode, that is with ``as_sql=True``, the ``starting_rev``
parameter is returned instead, if any.
"""
if self.as_sql:
return self._start_from_rev
else:
if self._start_from_rev:
raise util.CommandError(
"Can't specify current_rev to context "
"when using a database connection")
self._version.create(self.connection, checkfirst=True)
return self.connection.scalar(self._version.select())
评论列表
文章目录