问题描述
我已经使用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.
这篇关于无法完成烧瓶迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!