In my flask project I wrote on my manage.py file:
from app import app, db
from flask_script import Manager, Shell
from flask_migrate import Migrate, MigrateCommand
migrate = Migrate(app, db)
manager = Manager(app)
manager.add_command('db', MigrateCommand)
def make_shell_context():
return dict(app=app, db=db)
manager.add_command("shell", Shell(make_context=make_shell_context))
if __name__ == '__main__':
manager.run()
I've two models, user and dashboard. The idea is, in my postgres database user
table would be in the default public schema
and after creating a new user I need to create a private schema
where the dashboard table will be created.
For the default public schema we usually run python manage.py db migrate
. It'll then create the tables in default public schema. But what should I do in my case?
First I've to run migrate command to generate the User
table in public schema. Then after adding a successful row in user table I need to run a script for creating a private schema where a new table dashboard
will be generated. How can I achieve this?