aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/db/sql/migration_tools.py
diff options
context:
space:
mode:
authorElrond <elrond+mediagoblin.org@samba-tng.org>2012-12-13 12:35:27 +0100
committerElrond <elrond+mediagoblin.org@samba-tng.org>2013-01-08 22:50:01 +0100
commitc4466cb4dcf194f634b6fe855f5e5fad09e70df1 (patch)
tree67adca82eb905486c598aa2de861527e4496ce0f /mediagoblin/db/sql/migration_tools.py
parenta050e776c6d9c4970dd241e92b2f24a8c9deb36d (diff)
downloadmediagoblin-c4466cb4dcf194f634b6fe855f5e5fad09e70df1.tar.lz
mediagoblin-c4466cb4dcf194f634b6fe855f5e5fad09e70df1.tar.xz
mediagoblin-c4466cb4dcf194f634b6fe855f5e5fad09e70df1.zip
Add inspect_table.
In our current scheme of migrations, we reflect the current sql schema into an SQLAlchemy schema. So let's have a tool function for this.
Diffstat (limited to 'mediagoblin/db/sql/migration_tools.py')
-rw-r--r--mediagoblin/db/sql/migration_tools.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/mediagoblin/db/sql/migration_tools.py b/mediagoblin/db/sql/migration_tools.py
index ee84e06f..e5380a3b 100644
--- a/mediagoblin/db/sql/migration_tools.py
+++ b/mediagoblin/db/sql/migration_tools.py
@@ -15,6 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from mediagoblin.tools.common import simple_printer
+from sqlalchemy import Table
class MigrationManager(object):
@@ -261,3 +262,9 @@ def assure_migrations_table_setup(db):
if not MigrationData.__table__.exists(db.bind):
MigrationData.metadata.create_all(
db.bind, tables=[MigrationData.__table__])
+
+
+def inspect_table(metadata, table_name):
+ """Simple helper to get a ref to an already existing table"""
+ return Table(table_name, metadata, autoload=True,
+ autoload_with=metadata.bind)