diff options
author | Rodney Ewing <ewing.rj@gmail.com> | 2013-09-02 09:47:55 -0700 |
---|---|---|
committer | Rodney Ewing <ewing.rj@gmail.com> | 2013-09-02 11:53:48 -0700 |
commit | 26583b2cab650cc27af845fd2ef20cccae2aeceb (patch) | |
tree | 351de395d0ad7b29c1402f52e19743c08843a10f /mediagoblin/db/util.py | |
parent | dd57c6c5e51a62875542446e0432f850f0239ef8 (diff) | |
download | mediagoblin-26583b2cab650cc27af845fd2ef20cccae2aeceb.tar.lz mediagoblin-26583b2cab650cc27af845fd2ef20cccae2aeceb.tar.xz mediagoblin-26583b2cab650cc27af845fd2ef20cccae2aeceb.zip |
check if db is up to date
Diffstat (limited to 'mediagoblin/db/util.py')
-rw-r--r-- | mediagoblin/db/util.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/mediagoblin/db/util.py b/mediagoblin/db/util.py index 8431361a..19e23d7f 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 @@ -68,6 +71,18 @@ def check_collection_slug_used(creator_id, slug, ignore_c_id): 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 the webserver.") + + if __name__ == '__main__': from mediagoblin.db.open import setup_connection_and_db_from_config |