title: Flask-Migrate No Changes Detected to Schema on first migration
body: <p>I'm using Flask with Flask-SQLAlchemy and Flask-Migrate to create an application, however when I try to create a migration nothing happens. </p>
  
  <p>I've created two tables in <code>app/models.py</code>:</p>
  
  <pre><code>from flask import current_app
  from . import db
  
  class Student(db.Model):
      __tablename__ = 'students'
      id = db.Column(db.Integer, primary_key=True)
      email = db.Column(db.String(64), unique=True, nullable=False)
      password_hash = db.Column(db.String(128))
  
      def __init__(self, **kwargs):
          super(Student, self).__init__(**kwargs)
  
      def __repr__(self):
          return '&lt;Tutor {}&gt;' % self.id
  
  class Tutor(db.Model):
      __tablename__ = 'tutors'
      id = db.Column(db.Integer, primary_key=True)
      email = db.Column(db.String(64), unique=True, index=True)
      password_hash = db.Column(db.String(128))
  
      def __init__(self, **kwargs):
          super(Tutor, self).__init__(**kwargs)
      def __repr__(self):
          return '&lt;Student %r&gt;' % self.id
  </code></pre>
  
  <p>Then I also have <code>app/__init__.py</code> with the following code:</p>
  
  <pre><code>from flask import Flask
  from flask_bootstrap import Bootstrap
  from flask_sqlalchemy import SQLAlchemy
  from flask_migrate import Migrate
  
  #from .models import User, Task, Project, UserProject
  
  from config import config
  
  bootstrap = Bootstrap()
  db = SQLAlchemy()
  migrate = Migrate()
  
  def create_app(config_name='default'):
      #print config_name.name
      app = Flask(__name__)
      app.config.from_object(config[config_name])
      config[config_name].init_app(app)
  
      bootstrap.init_app(app)
      db.init_app(app)
      migrate.init_app(app, db)
  
      ## Register the main blueprint for main app functionality
      from .main import main as main_blueprint
      app.register_blueprint(main_blueprint)
  
      return app
  </code></pre>
  
  <p>and <code>app.py</code>:</p>
  
  <pre><code>import os
  from app import create_app, db
  from app.models import Tutor, Student
  
  app = create_app('default')
  
  @app.shell_context_processor
  def make_shell_context():
      return dict(db=db, Tutor=Tutor, Student=Student)
  </code></pre>
  
  <p>I can run <code>flask db init</code> with no problem and it creates the migrations directory and all necessary files with the following output:</p>
  
  <pre><code>Creating directory /Users/Jasmine/projects/flask/flask-tutoring/migrations ... done
  Creating directory /Users/Jasmine/projects/flask/flask-tutoring/migrations/versions ... done
  Generating /Users/Jasmine/projects/flask/flask-tutoring/migrations/script.py.mako ... done
  Generating /Users/Jasmine/projects/flask/flask-tutoring/migrations/env.py ... done
  Generating /Users/Jasmine/projects/flask/flask-tutoring/migrations/README ... done
  Generating /Users/Jasmine/projects/flask/flask-tutoring/migrations/alembic.ini ... done
  Please edit configuration/connection/logging settings in '/Users/Jasmine/projects/flask/flask-tutoring/migrations/alembic.ini' before proceeding.
  </code></pre>
  
  <p>but when I try and run <code>flask db migrate</code> alembic can't detect that I've got tables in <code>app/models.py</code>. I get the following output:</p>
  
  <pre><code>INFO  [alembic.runtime.migration] Context impl SQLiteImpl.
  INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
  INFO  [alembic.env] No changes in schema detected.
  </code></pre>
  
  <p>There is no migration script created, its as though <code>models.py</code> doesn't exist.</p>
  
  <p>Apologies if this is a repeated question, but I can't find another example where its the first migration that fails and no migration script at all is created.</p>
  
  <p>I've tried checking if there is already a table created somewhere by running <code>db.drop_all()</code> in the shell but that doesn't seem to be the problem.</p>
  
  <h2>UPDATE</h2>
  
  <p>I figured out a way to solve this on my own but would like a better understanding of why this worked.</p>
  
  <p>I re-named <code>app.py</code> to <code>flasktutor.py</code> and re-ran <code>export FLASK_APP='flasktutor.py'</code>. Subsequently the migration worked perfectly.</p>
  
  <p>Please could someone explain why when the file was called <code>app.py</code> and I used <code>export FLASK_APP='app.py'</code> the migration did not register changes to the schema.</p>