如何迁移我的heroku数据库?

时间:2023-01-13 13:27:00

I've tried:

我试过了:

heroku rake db:migrate

heroku rake db:migrate

and

heroku pg:push

heroku pg:推

The first gives me a PGerror / rake aborted error.

第一个给我一个PGerror / rake中止错误。

Is there a way to completely rebuild/reset my database with heroku? I can't seem to find it in their documentation.

有没有办法用heroku完全重建/重置我的数据库?我似乎无法在他们的文档中找到它。

EDIT: I had a working database before this, but my tables and relationships have changed.

编辑:在此之前我有一个工作数据库,但我的表和关系已经改变。

4 个解决方案

#1


15  

If you had a working database, you could recreate your tables from the schema:

如果您有一个工作数据库,则可以从架构重新创建表:

heroku run rake db:schema:load

If you want to just reset the database to empty:

如果您只想将数据库重置为空:

heroku run rake db:create

What is the error it is giving you? It might be more helpful to try to solve that problem rather than wipe everything.

它给你带来的错误是什么?尝试解决该问题而不是擦除所有内容可能更有帮助。

#2


4  

This should be updated as heroku rake has been deprecated. Use heroku run rake now. See below, per command-line/stderr output, as of today (March 8, 2013):

这应该更新,因为heroku rake已被弃用。现在使用heroku run rake。根据今天(2013年3月8日)的命令行/ stderr输出,请参见下文:


Incorrect:

不正确:

  • PROMPT>heroku rake db:migrate --app myApp

    WARNING: 'heroku rake'` has been deprecated. Please use 'heroku run rake' instead.

    警告:'heroku rake'已被弃用。请改用'heroku run rake'。


Correct:

正确:

  • PROMPT>heroku run rake db:migrate --app myApp

    Running rake db:migrate attached to terminal... up, run.2810

    运行rake db:migrate连接到终端... up,run.2810

#3


1  

Try:

尝试:

 heroku rake db:migrate VERSION=0

This will get your database to its starting point.

这将使您的数据库到达起点。

#4


0  

heroku run rake db:migrate -a appname

#1


15  

If you had a working database, you could recreate your tables from the schema:

如果您有一个工作数据库,则可以从架构重新创建表:

heroku run rake db:schema:load

If you want to just reset the database to empty:

如果您只想将数据库重置为空:

heroku run rake db:create

What is the error it is giving you? It might be more helpful to try to solve that problem rather than wipe everything.

它给你带来的错误是什么?尝试解决该问题而不是擦除所有内容可能更有帮助。

#2


4  

This should be updated as heroku rake has been deprecated. Use heroku run rake now. See below, per command-line/stderr output, as of today (March 8, 2013):

这应该更新,因为heroku rake已被弃用。现在使用heroku run rake。根据今天(2013年3月8日)的命令行/ stderr输出,请参见下文:


Incorrect:

不正确:

  • PROMPT>heroku rake db:migrate --app myApp

    WARNING: 'heroku rake'` has been deprecated. Please use 'heroku run rake' instead.

    警告:'heroku rake'已被弃用。请改用'heroku run rake'。


Correct:

正确:

  • PROMPT>heroku run rake db:migrate --app myApp

    Running rake db:migrate attached to terminal... up, run.2810

    运行rake db:migrate连接到终端... up,run.2810

#3


1  

Try:

尝试:

 heroku rake db:migrate VERSION=0

This will get your database to its starting point.

这将使您的数据库到达起点。

#4


0  

heroku run rake db:migrate -a appname