old_contents: import os
  
  from app import create_app, db
  from app.models import User, Role, Permission, Post, Comment
  from flask_script import Manager, Shell
  from flask_migrate import Migrate, MigrateCommand
  
  app = create_app(os.environ.get('CONFIG') or 'default')
  manmager = Manager(app)
  migrate = Migrate(app, db)
  
  def make_shell_context():
      return dict(app=app, db=db, User=User, Role=Role, Permission=permission,
                  Post=Post, Comment=Comment)
  manager.add_command("shell", Shell(make_contex=make_shell_context()))
  manager.add_command('db', MigrateCommand)
  
  if __name__ == '__main__':
      manager.run()
new_contents: import os
  
  from app import create_app, db
  from app.models import User, Role, Permission, Post, Comment
  from flask_script import Manager, Shell
  from flask_migrate import Migrate, MigrateCommand
  
  app = create_app(os.environ.get('CONFIG') or 'default')
  manmager = Manager(app)
  migrate = Migrate(app, db)
  
  def make_shell_context():
      return dict(app=app, db=db, User=User, Role=Role, Permission=permission,
                  Post=Post, Comment=Comment)
  manager.add_command("shell", Shell(make_contex=make_shell_context()))
  manager.add_command('db', MigrateCommand)
  
  @manager.command
  def deploy():
      from flask_migrate import upgrade
      from app.models import Role, User
  
      upgrade()
      Role.insert_roles()
      User.add_self_follows()
  
  if __name__ == '__main__':
      manager.run()
subject: add deploy function