无法完成烧瓶迁移

编程入门 行业动态 更新时间:2024-10-28 08:22:41
本文介绍了无法完成烧瓶迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经使用SQLAlchemy设置了本地Postgres数据库,但是无法提交我的第一条记录。我不断收到此错误...

I've setup a local Postgres DB with SQLAlchemy and cannot commit my first entry. I keep on getting this error...

ProgrammingError: (ProgrammingError) relation "user" does not exist LINE 1: INSERT INTO "user" (name, email, facebook_id, facebook_token...

我尝试使用flask-migrate进行迁移,但是当我运行 $ python app.py db migration 时,我得到了这个错误...

It seems like the fields aren't matching to those in the database. I'm trying to migrate using flask-migrate but, when I run $ python app.py db migrate I get this error...

raise util.CommandError("No such revision '%s'" % id_) alembic.util.CommandError: No such revision '39408d6b248d'

最好删除所有内容并从

更新:数据库具有现在开始工作(我删除并再次创建它)。但是,尝试运行迁移时仍然遇到相同的错误,结果是没有这样的修订'39408d6b248d'引用从无关项目的迁移。我重新安装了flask-migrate,但存在相同的错误。

UPDATE: The database has started working now (I dropped and created it again). However, I'm still getting the same error trying to run migrations and it turns out the "no such revision '39408d6b248d' is referring to a migration from an unrelated project. I re-installed flask-migrate but same error.

推荐答案

flask-migrate将在数据库中创建一个名为 alembic_version的表。 应该删除该表并删除项目中的migrations文件夹。 ,然后再次使用 $ python app.py db init ... 我认为 $ python app.py db migration 可以正常工作。

flask-migrate will create a table named "alembic_version" in your database. so you should drop this table and delete migrations folder in your project. and then use $ python app.py db init again... I think $ python app.py db migrate will work fine.

更多推荐

无法完成烧瓶迁移

本文发布于:2023-10-17 22:05:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1502208.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:烧瓶

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!