首页 > 解决方案 > Load more than one database for a single project

问题描述

Does anyone know if there a way I can have more than one db associated with a single Ddev project?

I'm working on a version-controlled project which uses Ddev as the hosting environment. I want to run an upgrade on a CMS in my project and have created a new branch for the purpose and would like to create a separate database for the upgrade too so that when I switch between branches it switches database too.

But it seems that Ddev only allows one db to be linked to a project at one time.

This Github issue suggests creating a separate Ddev project for each Git branch but because everything in my repos also gets deployed to branches on the server, they'd end up with Ddev config files that they don't need, so I'd like to avoid that.

标签: gitddev

解决方案


你打赌,ddev import-db接受一个--target-db 参数,所以你可以ddev import-db --src=/path/to/import.sql.gz --target-db=myseconddb,它会自动创建一个名为“myseconddb”的新数据库。

这也包含在“我可以使用其他数据库”下的ddev 常见问题解答中。

在DDEV-本地数据库管理一文中,还全面讨论了管理数据库的所有方法


推荐阅读