管理数据库更改的最佳方法

时间:2023-01-14 20:07:00

What is the best way to manage database changes? I need to have a solutions regardless the database client's language. Also I'd like to be able to use specific database features in those changes such as stored procedures, triggers and so on.

管理数据库更改的最佳方法是什么?无论数据库客户端的语言如何,我都需要一个解决方案。此外,我希望能够在这些更改中使用特定的数据库功能,例如存储过程,触发器等。

6 个解决方案

#1


13  

First of all, make sure you have your entire Database Build scripted so you can rebuild the database if needed.

首先,确保您编写了整个Database Build脚本,以便在需要时重建数据库。

Each change should then be written as an Update script. That way you can run each change individually against the your databases.

然后应将每个更改写为更新脚本。这样,您可以针对数据库单独运行每个更改。

Once the change has been commited to the codebase, merge the change script with the build process so it happens automatically...and then archive the change script in case any questions arise.

将更改提交到代码库后,将更改脚本与构建过程合并,以便自动发生...然后存档更改脚本以防出现任何问题。

#2


7  

First and foremost, put all database changes in scripts and put them into the source control system.

首先,将所有数据库更改放在脚本中并将它们放入源代码管理系统中。

Next remove any permissions to production that developers have. Exactly two people should have rights on production in a small to medium shop, the designated dba and his or her designated alternate. Once devs can't make changes to prod, you will find it easier to get them to actually write and use scripts.

接下来删除开发人员拥有的任何生产权限。在中小型商店,指定的dba和他或她指定的候补商品中,正好有两个人应该拥有生产权。一旦开发人员无法对prod进行更改,您会发现更容易让他们实际编写和使用脚本。

Never run a script on prod that wasn't first loaded to QA or staging. If there are issues with the script, it should be found at this point.

永远不要在首次加载到QA或暂存的prod上运行脚本。如果脚本存在问题,则应在此处找到。

#3


4  

Use idempotent change scripts (and maybe have a look at LiquiBase or dbdeploy).

使用幂等更改脚本(也许可以查看LiquiBase或dbdeploy)。

#4


1  

Not sure what you are asking here, but if it's a good way to manage schema changes, and keeping them in synch between versions and deployments, it's hard to go wrong with Visual Studio Database Edition. It's sole purpose in life is to manage database schema changes, validate the schema, build and generate deployment scripts. If you have Visual Studio Developer Edition or Visual Studio Team Suite, you can get it for free.

不确定你在这里问什么,但如果它是管理模式更改的好方法,并且在版本和部署之间保持同步,那么Visual Studio数据库版很难出错。生命中唯一的目的是管理数据库模式更改,验证模式,构建和生成部署脚本。如果您有Visual Studio Developer Edition或Visual Studio Team Suite,则可以免费获得。

#5


0  

Well, we are currently using Redgate's toolbelt which contains a Database Compare, Data Compare, etc.

好吧,我们目前正在使用Redgate的工具带,其中包含数据库比较,数据比较等。

You can also use any source control to track changes to your database objects.

您还可以使用任何源代码控制来跟踪对数据库对象的更改。

#6


0  

In my case, I build a SH script for this work:

在我的例子中,我为这项工作构建了一个SH脚本:

https://github.com/reduardo7/db-version-updater

https://github.com/reduardo7/db-version-updater

And a MySQL script:

还有一个MySQL脚本:

https://github.com/reduardo7/db-version-updater-mysql

https://github.com/reduardo7/db-version-updater-mysql

#1


13  

First of all, make sure you have your entire Database Build scripted so you can rebuild the database if needed.

首先,确保您编写了整个Database Build脚本,以便在需要时重建数据库。

Each change should then be written as an Update script. That way you can run each change individually against the your databases.

然后应将每个更改写为更新脚本。这样,您可以针对数据库单独运行每个更改。

Once the change has been commited to the codebase, merge the change script with the build process so it happens automatically...and then archive the change script in case any questions arise.

将更改提交到代码库后,将更改脚本与构建过程合并,以便自动发生...然后存档更改脚本以防出现任何问题。

#2


7  

First and foremost, put all database changes in scripts and put them into the source control system.

首先,将所有数据库更改放在脚本中并将它们放入源代码管理系统中。

Next remove any permissions to production that developers have. Exactly two people should have rights on production in a small to medium shop, the designated dba and his or her designated alternate. Once devs can't make changes to prod, you will find it easier to get them to actually write and use scripts.

接下来删除开发人员拥有的任何生产权限。在中小型商店,指定的dba和他或她指定的候补商品中,正好有两个人应该拥有生产权。一旦开发人员无法对prod进行更改,您会发现更容易让他们实际编写和使用脚本。

Never run a script on prod that wasn't first loaded to QA or staging. If there are issues with the script, it should be found at this point.

永远不要在首次加载到QA或暂存的prod上运行脚本。如果脚本存在问题,则应在此处找到。

#3


4  

Use idempotent change scripts (and maybe have a look at LiquiBase or dbdeploy).

使用幂等更改脚本(也许可以查看LiquiBase或dbdeploy)。

#4


1  

Not sure what you are asking here, but if it's a good way to manage schema changes, and keeping them in synch between versions and deployments, it's hard to go wrong with Visual Studio Database Edition. It's sole purpose in life is to manage database schema changes, validate the schema, build and generate deployment scripts. If you have Visual Studio Developer Edition or Visual Studio Team Suite, you can get it for free.

不确定你在这里问什么,但如果它是管理模式更改的好方法,并且在版本和部署之间保持同步,那么Visual Studio数据库版很难出错。生命中唯一的目的是管理数据库模式更改,验证模式,构建和生成部署脚本。如果您有Visual Studio Developer Edition或Visual Studio Team Suite,则可以免费获得。

#5


0  

Well, we are currently using Redgate's toolbelt which contains a Database Compare, Data Compare, etc.

好吧,我们目前正在使用Redgate的工具带,其中包含数据库比较,数据比较等。

You can also use any source control to track changes to your database objects.

您还可以使用任何源代码控制来跟踪对数据库对象的更改。

#6


0  

In my case, I build a SH script for this work:

在我的例子中,我为这项工作构建了一个SH脚本:

https://github.com/reduardo7/db-version-updater

https://github.com/reduardo7/db-version-updater

And a MySQL script:

还有一个MySQL脚本:

https://github.com/reduardo7/db-version-updater-mysql

https://github.com/reduardo7/db-version-updater-mysql