aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/db/util.py
diff options
context:
space:
mode:
authorjpope <jpope@jpope.org>2014-01-05 16:55:58 -0600
committerjpope <jpope@jpope.org>2014-01-05 16:55:58 -0600
commit0172ad000148f1cfe6f5110982c364f46b3d0ecb (patch)
treea32f97b2cc6fa6fb41de8263f8c6136922e87799 /mediagoblin/db/util.py
parent1e298b10c7cba2d27cb19f1aee03134f66ef6e20 (diff)
parent64eab630bf99e4d92e567628dbfc7cecf4cc27c4 (diff)
downloadmediagoblin-0172ad000148f1cfe6f5110982c364f46b3d0ecb.tar.lz
mediagoblin-0172ad000148f1cfe6f5110982c364f46b3d0ecb.tar.xz
mediagoblin-0172ad000148f1cfe6f5110982c364f46b3d0ecb.zip
Merge remote-tracking branch 'upstream/master' into skeletongobblin
Diffstat (limited to 'mediagoblin/db/util.py')
-rw-r--r--mediagoblin/db/util.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/mediagoblin/db/util.py b/mediagoblin/db/util.py
index 7a0a3a73..aba9c59c 100644
--- a/mediagoblin/db/util.py
+++ b/mediagoblin/db/util.py
@@ -14,9 +14,12 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+import sys
+
+from mediagoblin import mg_globals as mgg
from mediagoblin.db.base import Session
from mediagoblin.db.models import MediaEntry, Tag, MediaTag, Collection
-
+from mediagoblin.gmg_commands.dbupdate import gather_database_data
##########################
# Random utility functions
@@ -67,6 +70,19 @@ def check_collection_slug_used(creator_id, slug, ignore_c_id):
does_exist = Session.query(Collection.id).filter(filt).first() is not None
return does_exist
+
+def check_db_up_to_date():
+ """Check if the database is up to date and quit if not"""
+ dbdatas = gather_database_data(mgg.global_config.get('plugins', {}).keys())
+
+ for dbdata in dbdatas:
+ migration_manager = dbdata.make_migration_manager(Session())
+ if migration_manager.database_current_migration is None or \
+ migration_manager.migrations_to_run():
+ sys.exit("Your database is not up to date. Please run "
+ "'gmg dbupdate' before starting MediaGoblin.")
+
+
if __name__ == '__main__':
from mediagoblin.db.open import setup_connection_and_db_from_config