I am coming from Django background. In flask I am looking for the migration command. How should I use the migration-script for this purpose. I referred the document(https://flask-migrate.readthedocs.io/en/latest/#using-flask-script) for the same.
My project structure is like.
- service
- init.py
- models
- init.py
- employee.py (contains model declaration)
- manage.py
- app.py (start point of project)
- urls.py (Used blueprint for url routing)
As per the document if I written my models in manage.py file then it will work as expected. But I have models folder where I am writing all the models. So if I hit python3 manage.py db migrate
command it will not detect any changes from the models file.
- Imported model in init.py file of the models.
- imported models in manage.py file.
Manage.py file.
from flask_migrate import Migrate, MigrateCommand
from flask_script import Manager
from app import app, db
migrate = Migrate(app, db)
manager = Manager(app)
manager.add_command('db', MigrateCommand)
if __name__ == '__main__':
manager.run()
Currently it will only create alembic_version table in my database
This is the output
>> python3 manage.py db migrate
INFO [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO [alembic.runtime.migration] Will assume transactional DDL.
INFO [alembic.env] No changes in schema detected.