flask: error: unrecognized arguments: db migrate

Viewed 308

I have a flask app and have managed to run db init on it. Now I'd like to add a column to the db and thus migrate it. When I type flask db migrate in my terminal (from within my virtualenv) I get an error:

usage: flask [-h] [--port PORT]
flask: error: unrecognized arguments: db migrate

This is strange because flask db --help does give me the menu options for flask db. Here is my app's __init__.py file :

from flask import Flask
from flask_sqlalchemy import SQLAlchemy
import os
from flask_migrate import Migrate

app=Flask(__name__)

SECRET_KEY = os.urandom(32)
app.config['SECRET_KEY'] = SECRET_KEY

basedir = os.path.abspath(os.path.dirname(__file__))
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///'+os.path.join(basedir, 'data.sqlite')
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

db = SQLAlchemy(app)
migrate = Migrate(app, db)

This is my models.py:

from healthycart import db
from datetime import datetime


class User(db.Model):
    __tablename__ = 'users'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64))
    email = db.Column(db.String(64))
    zipcode = db.Column(db.String(64))
    meal_plan = db.Column(db.Integer)
    date_joined = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)

    def __init__(self, name, email, zipcode):
        self.name = name
        self.email = email
        self.zipcode = zipcode
        self.meal_plan = None

The other columns are already there - I just want to add the "zipcode" column.

0 Answers
Related