一次更改多个 mysql 数据库(SAAS 数据库更改)
我们正在运行一个 PHP(zend 框架)应用程序,它为每个用户创建一个数据库(出于安全/备份/和其他原因)。 所有这些数据库都具有完全相同的结构,而且情况始终如此。当我们部署新功能时,我们需要使用新字段/表扩展所有数据库。
我已经读过有关使用 dbdeploy 的内容,但我不确定它们是否同时支持多个数据库(无需一一给出名称)。数据库称为 user1、user2、user3 等。
有没有什么好的工具可以让我们的这个过程变得更容易、更少痛苦? 我们正在运行 phing 进行自动化部署,并找到了指南 http://www.davedevelopment.co.uk/2008/04/14/how-to-simple-database-migrations-with-phing-and-dbdeploy/ 不如此有用,因为它们不像我们那样支持多个数据库。
此外,我们可以使用 Windows 或 Mac mysql 客户端来执行此操作,因此我们对任何内容都持开放态度
We are running a PHP (zend framework) app that creates a database per user (for security/backup/and others reasons).
All these databases have exactly the same structure and that will always be the case. When we deploy new features we'll need to expand all databases with the new fields/tables.
I've read about using dbdeploy for that, but I'm not sure that they support multiple databases at once (without giving in the names one by one). Databases are called user1, user2, user3 and so on.
Are there any good tools that will make this process for us a bit easier and less painful?
We are running phing for automated deployment and found the guide http://www.davedevelopment.co.uk/2008/04/14/how-to-simple-database-migrations-with-phing-and-dbdeploy/ not so useful because they don't support multiple databases like we have.
Also, windows or mac mysql clients that can do this are possible for us, so we are open for anything
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是我为您整理的 PHP 脚本。如果数据库名称以
user
开头,它会获取所有数据库的列表并应用更新。我还让它在应用更改之前备份每个数据库。备份部分目前特定于 Linux/Unix,但可以对其进行调整以在其他操作系统上工作。
目前它非常冗长,因此您可以根据需要进行更改。您还可以更改行终止符,具体取决于您是从 CLI 还是浏览器运行它。我建议将其放在您的脚本目录中并从 CLI 运行它。
如果您需要其他任何东西或者这对您不起作用,请告诉我。
Here is a PHP script that I put together for you. It gets a list of all databases and applies the updates if the database name begins with
user
.I also have it backup each database before it applies the changes. The backup portion is specific to Linux/Unix right now, but it can be tweaked to work on other operating systems.
It is pretty verbose at the moment, so you can change it as needed. You can also change the line terminator, depending if you will be running it from the CLI or a browser. I would suggest to put this in your scripts directory and run it from the CLI.
Let me know if you need anything else or if this doesn't work for you.