Add a script to force migration of lazy tables and fix missing options in DAL init.
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
To use, e.g. python .\web2py.py -S APPNAME --force_migrate
|
||||
'''
|
||||
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger("web2py")
|
||||
|
||||
|
||||
def get_databases(request):
|
||||
dbs = {}
|
||||
global_env = globals()
|
||||
for (key, value) in global_env.items():
|
||||
try:
|
||||
cond = isinstance(value, GQLDB)
|
||||
except:
|
||||
cond = isinstance(value, SQLDB)
|
||||
if cond:
|
||||
dbs[key] = value
|
||||
return dbs
|
||||
|
||||
|
||||
logger.debug('Getting all databases')
|
||||
databases = get_databases(None)
|
||||
logger.debug('databases = %s', databases)
|
||||
for db_name in databases:
|
||||
logger.debug('Migrating %s', db_name)
|
||||
db = databases[db_name]
|
||||
tables = db.tables
|
||||
for table_name in tables:
|
||||
# Force migration of lazy tables
|
||||
logger.debug("Ensuring migration of table '%s'", table_name)
|
||||
db(db[table_name]).isempty()
|
||||
db.commit()
|
||||
Reference in New Issue
Block a user