未检测到架构更改

时间:2018-07-27 15:45:39

标签: python enums sqlalchemy alembic

环境: alembic == 0.8.4 SQLAlchemy == 1.0.10 烧瓶== 0.10.1 烧瓶棉花糖== 0.6.2 Flask-Migrate == 1.6.0 Flask-RESTful == 0.3.4 flask-restful-swagger == 0.19 Flask-Script == 2.0.5 Flask-SSLify == 0.1.5

带有迁移文件的数据库原始模型

from sqlalchemy import Column
from sqlalchemy.dialects.mysql import INTEGER
import enum
from sqlalchemy.dialects.mysql import ENUM
from mapping_service.app import db


class MappingStatusEnum(enum.Enum):
    OVERRIDDEN = 'overridden'
    SUGGESTION = 'suggestion'


    @staticmethod
    def list():
        return list(map(lambda status: status.value, MappingStatusEnum))

class MappingStatus(db.Model):
    __tablename__ = "MappingStatus"
    __table_args__ = {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}

    id = Column(INTEGER(unsigned=True),
                primary_key=True,
                autoincrement=True,
                nullable=False)
    status = Column(ENUM(*MappingStatusEnum.list()), unique=True, nullable=False)

数据库模型已更改,但未检测到架构更改

 class MappingStatusEnum(enum.Enum):
        OVERRIDDEN = 'overridden'
        SUGGESTION = 'suggestion'
        REJECTED = 'rejected'
        FAILED = 'failed'

如您所见,我已经更改了可能的状态并添加了两个新状态。执行时

python manange.py db migrate

我得到的是以下消息:

INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.env] No changes in schema detected.

我该怎么做,以便Alembic可以看到架构更改并创建适当的迁移文件?我不太熟悉Flask,精通SQLAlchemy,所以我可能正在做一些非常愚蠢的事情,我无法弄清。

0 个答案:

没有答案