I was having difficulty migrating updates to my table model using Flask-SQLALchemy library
After making changes to my table schema, I ran the migrate command and the response suggested there were no changes...
$ python 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.
models.py file
from sqlalchemy.dialects.postgresql import JSON
from app import db
class Result(db.Model):
__tablename__ = 'results'
id = db.Column(db.Integer, primary_key=True)
url = db.Column(db.String())
datetime = db.Column(db.String())
results = db.Column(JSON)
errors = db.Column(JSON)
def __init__(self, url, datetime, results, errors=None):
self.url = url
self.datetime = datetime
self.results = results
self.errors = errors
def __repr__(self):
return f"<id {self.id}>"
manage.py file
import os
import json
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
from app import app, db
app.config.from_object(os.environ['APP_SETTINGS'])
migrate = Migrate(app, db)
manager = Manager(app)
manager.add_command('db', MigrateCommand)
if __name__ == '__main__':
manager.run()