Migration files not created #433
-
hello: ### this is the main py file
import os
from flask import Flask
from flask_migrate import Migrate
from flask_sqlalchemy import SQLAlchemy
## set directory to work with
basedir = os.path.abspath(os.path.dirname(__file__))
## set the app name = app
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///'+os.path.join(basedir,'data.sqlite')
app.config['SQLALCHEMY_TRA CK_MODIFICATIONS'] = False
db = SQLAlchemy(app)
migrate = Migrate(app, db)
class user(db.Model):
__tablename__ = 't_users'
uname = db.Column(db.String, primary_key=True , index=True)
email = db.Column(db.String(64) , index=True , unique=True)
upass = db.Column(db.String(128), index=True, unique=True)
def __init__(self, uname, email, upass):
self.uname = uname
self.email = email
self.upass = upass #terminal commands to generate migration depository
export FLASK_APP=flask_exc_82_dba1.py
python3 -m flask db init
## migration depository created
python3 flask db migrate -m "user"
## generate migration file note that I am not working in a virtual environment that's why I call they python 3 command .. the FLASK_APP is also not picking the original file name so I am using the actual py file name
python3 flask_exc_82_dba1.py migrate -m "user"
## output from terminal
<SQLAlchemy engine=sqlite:////Users/karimkhalil/python_docs/web_dev/Examples/data.sqlite>
/Users/karimkhalil/python_docs/web_dev/Examples |
Beta Was this translation helpful? Give feedback.
Answered by
miguelgrinberg
Sep 8, 2021
Replies: 1 comment 1 reply
-
Use
If that does not work, please provide the complete output of the command. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
kimzwegz
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use
python3 -m flask db ...
when you send your migrate command:If that does not work, please provide the complete output of the command.