upgrade models.py
flask-sqlalchemy bugged when  a table contains a foreign key reference to itself (remote_id)
Delete sqlalchemy in the tables  declaration.