更新时间:2023-08-24 14:08:52
有几个不错的选择.我不会使用恢复备份"策略.
There are a couple of good options. I wouldn't use the "restore a backup" strategy.
为所有架构更改编写脚本,并让 CI 服务器在数据库上运行这些脚本.有一个版本表来跟踪当前的数据库版本,并且只有在更新版本时才执行脚本.
Script all your schema changes, and have your CI server run those scripts on the database. Have a version table to keep track of the current database version, and only execute the scripts if they are for a newer version.
使用迁移解决方案.这些解决方案因语言而异,但对于 .NET,我使用 Migrator.NET.这允许您对数据库进行版本控制并在版本之间上下移动.您的架构是在 C# 代码中指定的.
Use a migration solution. These solutions vary by language, but for .NET I use Migrator.NET. This allows you to version your database and move up and down between versions. Your schema is specified in C# code.