old_contents: # -*- coding: utf-8 -*-
  #
  # -----------------------------------------------------------------------------------
  # Copyright (c) Microsoft Open Technologies (Shanghai) Co. Ltd.  All rights reserved.
  #
  # The MIT License (MIT)
  #
  # Permission is hereby granted, free of charge, to any person obtaining a copy
  # of this software and associated documentation files (the "Software"), to deal
  # in the Software without restriction, including without limitation the rights
  # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  # copies of the Software, and to permit persons to whom the Software is
  # furnished to do so, subject to the following conditions:
  #
  # The above copyright notice and this permission notice shall be included in
  # all copies or substantial portions of the Software.
  #
  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  # THE SOFTWARE.
  # -----------------------------------------------------------------------------------
  
  try:
      from hackathon.hmongo import db
      from hackathon.util import get_now
      from hackathon.constants import ADMIN_ROLE_TYPE, ReservedUser
  except ImportError:
      pass
  
  
  def setup_db():
      """Initialize db tables
  
      make sure database and user correctly created in mysql
      in case upgrade the table structure, the origin table need be dropped firstly
      """
      # init REQUIRED db data.
  
      # reserved user is deleted, may not need in mongodb implementation
  
      # default super admin
      admin = db.users.find_one({"name": "admin"})
      if not admin:
          admin = {
              "name": "admin",
              "nickname": "admin",
              "password": "e8104164dfc4a479e42a9f6c0aefd2be",
              "is_super": True,
              "profile": {}
          }
          db.users.insert_one(admin)
  
      db.client.close()
  
  
  setup_db()
  
new_contents: # -*- coding: utf-8 -*-
  #
  # -----------------------------------------------------------------------------------
  # Copyright (c) Microsoft Open Technologies (Shanghai) Co. Ltd.  All rights reserved.
  #
  # The MIT License (MIT)
  #
  # Permission is hereby granted, free of charge, to any person obtaining a copy
  # of this software and associated documentation files (the "Software"), to deal
  # in the Software without restriction, including without limitation the rights
  # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  # copies of the Software, and to permit persons to whom the Software is
  # furnished to do so, subject to the following conditions:
  #
  # The above copyright notice and this permission notice shall be included in
  # all copies or substantial portions of the Software.
  #
  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  # THE SOFTWARE.
  # -----------------------------------------------------------------------------------
  
  try:
      from hackathon.hmongo import db
  except ImportError:
      pass
  
  
  def setup_db():
      """Initialize db tables
  
      make sure database and user correctly created in db
      in case upgrade the table structure, the origin table need be dropped firstly
      """
      # init REQUIRED db data.
  
      # reserved user is deleted, may not need in mongodb implementation
  
      # default super admin
      admin = {
          "name": "admin",
          "nickname": "admin",
          "password": "e8104164dfc4a479e42a9f6c0aefd2be",
          "is_super": True,
          "profile": {}}
  
      db.user.update_one({"name": "admin"}, {"$set": admin}, upsert=True)
      db.client.close()
  
  
  setup_db()
  
subject: update setup_db to let it work properly