Tweak the uuid backfill to leave the uuid column nullable.
This commit is contained in:
parent
7c8a438b58
commit
e863b96166
3 changed files with 11 additions and 10 deletions
|
@ -1,7 +1,7 @@
|
|||
import logging
|
||||
import uuid
|
||||
|
||||
from data.database import User, configure, db
|
||||
from data.database import User, db
|
||||
from app import app
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
@ -11,15 +11,14 @@ def backfill_user_uuids():
|
|||
LOGGER.setLevel(logging.DEBUG)
|
||||
LOGGER.debug('User UUID Backfill: Began execution')
|
||||
|
||||
# Make sure we have a reference to the current DB.
|
||||
configure(app.config)
|
||||
LOGGER.debug('User UUID Backfill: Database configured')
|
||||
|
||||
# Check to see if any users are missing uuids.
|
||||
has_missing_uuids = bool(list(User
|
||||
.select(User.id)
|
||||
.where(User.uuid >> None)
|
||||
.limit(1)))
|
||||
has_missing_uuids = True
|
||||
try:
|
||||
User.select().where(User.uuid >> None).get()
|
||||
except User.DoesNotExist:
|
||||
has_missing_uuids = False
|
||||
|
||||
if not has_missing_uuids:
|
||||
LOGGER.debug('User UUID Backfill: No migration needed')
|
||||
return
|
||||
|
@ -46,6 +45,7 @@ def backfill_user_uuids():
|
|||
except User.DoesNotExist:
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
logging.getLogger('boto').setLevel(logging.CRITICAL)
|
||||
|
|
Reference in a new issue