在 Heroku 仪表板中销毁数据库后,如何将数据库重新提交到 Heroku

发布于 2025-01-15 10:06:53 字数 470 浏览 3 评论 0原文

我使用 Django 等构建了一个应用程序。在运行 heroku run python manage.py makemigrationsheroku run python 之前意外推送到生产环境后,我遇到了 Heroku 上的数据库的一大堆问题管理.py 迁移

我决定完全销毁 Heroku 上当前的数据库,并希望将我的应用程序的模型重新提交到 Heroku。我的希望是完全从头开始。

我只是想确保我正确执行此操作,因此我要求提供有关如何在销毁仪表板中的数据库后将应用程序的数据库重新提交到 Heroku 的明确说明。

我在线打开应用程序时遇到的当前错误是:

settings.DATABASES is improperly configured. Please supply the NAME or OPTIONS['service'] value.

谢谢!

I've built an app using Django etc. I ran into a whole bunch of problems with database on Heroku after accidentally pushing to production before running heroku run python manage.py makemigrations and heroku run python manage.py migrate.

I decided to just completely destroy the database currently on Heroku and want to recommit my app's models to heroku. My hope is to completely start from a clean slate.

I just want to make sure I do this correctly so I'm asking for clear instructions about how to recommit my app's database to Heroku after destroying the database in the dashboard.

Current error I get when I open my app online is:

settings.DATABASES is improperly configured. Please supply the NAME or OPTIONS['service'] value.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

来世叙缘 2025-01-22 10:06:53

如果您完全删除了数据库,则必须配置另一个数据库。假设您使用 Heroku Postgres1,您可以使用 Heroku CLI 来执行此操作,例如so

heroku addons:create heroku-postgresql:hobby-dev

在这里,我们要求 Heroku 使用免费的 hobby-dev 层配置 heroku-postgresql 插件。根据需要修改。

如果您愿意,您还可以使用仪表板配置加载项< /a>.

作为配置过程的一部分,Heroku Postgres 会自动为您的应用设置一个新的 DATABASE_URL。只要您的项目在删除旧数据库之前使用此变量,它就应该找到新数据库而不需要任何更改。


1如果您使用不同的数据库插件,解决方案应该或多或少相同。配置附加组件的新实例,让它设置其环境变量,如果您的应用程序在使用该变量之前应该自行选择它。

If you completely removed your database you'll have to provision another one. Assuming you are using Heroku Postgres¹, you can do that using the Heroku CLI like so:

heroku addons:create heroku-postgresql:hobby-dev

Here we are asking Heroku to provision the heroku-postgresql add-on using the free hobby-dev tier. Modify as needed.

You can also provision add-ons using the Dashboard if you prefer.

As part of the provisioning process, Heroku Postgres will automatically set a new DATABASE_URL for your app. As long as your project was using this variable before you deleted your old database, it should find the new database without requiring any changes.


¹If you were using a different database add-on the solution should be more or less the same. Provision a new instance of the add-on, let it set its environment variable, and if your app was using that variable before it should pick it up on its own.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文