如何在 DotCloud.com 上推送我的 Rails 应用程序的 Git 更新而不丢失 SQLite prod 数据库

发布于 2024-11-10 07:33:04 字数 251 浏览 8 评论 0原文

这可能是一个菜鸟问题,但到目前为止我找不到解决方案。 我正在本地开发一个使用 SQLite 的 Rails 应用程序,我已经设置了一个本地 Git 存储库,并且 dotcloud push 命令正在使用它。在本地,我使用开发环境,在 DotCloud 上它自动使用产品环境,这很棒。问题是,每次我在 DotCloud 上推送我的产品数据库时,无论代码库的更改有多么微小,我都会丢失,并且我必须运行“rake db:migrate”来再次设置它。我本地没有产品数据库,只有开发和测试数据库。

This could be a noob problem but I couldn't find a solution so far.
I'm developing a Rails app locally that uses SQLite, I've set up a local Git repo, and the dotcloud push command is using this. Locally I use the dev environment and on DotCloud it automatically uses the prod env, which is great. The problem is that each time I do a push my prod db on DotCloud gets lost, no matter how minor the changes are to the codebase, and I have to run 'rake db:migrate' to set it up again. I don't have a prod db locally, only the dev and test dbs.

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

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

发布评论

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

评论(4

〆一缕阳光ご 2024-11-17 07:33:04

按照此处所述将数据库放入 ~/data/ 并创建符号链接在部署时:

ln -s ~/data/production.sqlite3 ~/current/db/production.sqlite3

Put your DB in ~/data/ as described here and create a symbolic link at deploy time:

ln -s ~/data/production.sqlite3 ~/current/db/production.sqlite3
耳钉梦 2024-11-17 07:33:04

您不应该将 SQLite 数据库文件置于版本控制中。如果您有多个开发人员,那么每次有人合并最新更改时都会发生冲突。正如您所注意到的,它也将被推向生产。

您应该将 db 文件添加到 .gitignore。如果它已经在版本控制中,您可能必须先 git rm 该文件。

You should not have your SQLite database file in version control. If you had multiple developers it would conflict every single time somebody merges the latest changes. And as you've noticed, it will also be pushed up to production.

You should add the db file to .gitignore. If it's already in version control, you'll probably have to git rm the file first.

冷月断魂刀 2024-11-17 07:33:04

问题是,每次部署时,部署的应用程序的旧版本都会被擦除,并替换为新代码,并且您的 sqlite 数据库通常位于应用程序文件中。我不是 dotcloud 用户,我不知道它是否有效,但您可以尝试设置一个共享文件夹,将生产数据库放在服务器上,该服务器位于您的 Rails 应用程序之外。

The problem is that every time you deploy, the old version of your deployed app is wiped, and replaced with the new code, and your sqlite db is usually within your app files. I'm not a dotcloud user I don't know it it works, but you can try to setup a shared folder, where you put the production database on the server, which is outside of your rails app.

桃气十足 2024-11-17 07:33:04

不太确定 git 在 DotCloud.com 上是如何设置的,但我假设有一个您推送到的裸仓库,以及在执行合适的 git hook 时从裸仓库中提取的另一个仓库。您需要了解是否可以配置最后一次拉取以使用我们的合并策略。

Not really sure how git is setup on DotCloud.com, but I'm assuming there is a bare repo that you push to and another repo that pull from the bare when a suitable git hook has been executed. You need to find out if you can configure that last pull to use the ours merge strategy.

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