在迁移命令中未检测到烧瓶迁移已删除的列

时间:2020-04-14 11:05:47

标签: python sqlalchemy alembic flask-migrate sqlalchemy-migrate

我在使用postgresSQL的代码中有followig模型

    __tablename__ = 'person'
    __table_args__ = {'extend_existing': True}

    id = db.Column(UUID(as_uuid=True), primary_key=True, nullable=True)
    primary_areas = db.relationship('CauseCategory', secondary=interested_areas,
                                    backref=db.backref('persons', lazy='dynamic'))
    coins = db.Column(db.Integer, default=0)
    badge_type = db.Column(db.Enum(BadgeTypeEnum, default=BadgeTypeEnum.beginner), nullable=True)

    def save_to_db(self):
        db.session.add(self)
        db.session.commit()

    @classmethod
    def get_citizen(cls, cz_id):
        citizen = Citizen.query.filter_by(id=cz_id).first()
        return citizen

    @property
    def to_json(self):
        return {
            "id": str(self.id),
            "coins": self.coins,
            "badge": self.badge_type
        }

当我对此进行迁移时,它会为该模型正确地创建所有模型的表。这是我的第一次迁移。所以我以相同的顺序运行了以下命令

python manage.py db init
python manage.py db migrate
python manage.py db upgrade

我将compare_types标志设置为true

现在由于某种原因,我想摆脱上面模型中的硬币栏。所以我刚刚删除了这一行。然后我跑了

python manage.py db migrate

但它说

INFO  [alembic.env] No changes in schema detected
另一方面,当我向模型中添加另一列时,如下所示:

coins1 = db.Column(db.Integer, default=0)

它检测到它。

并且它也给了我以下几乎所有其他表的额外信息

INFO  [alembic.ddl.postgresql] Detected sequence named 'document_id_seq' as owned by integer column 'document(id)', assuming SERIAL and omitting

我在这里做什么错了?

0 个答案:

没有答案