将 SQL Server 数据库对象作为文件系统中的文件公开

2021-12-24 00:00:00 svn sql-server samba vfs

大多数版本控制工具在本地磁盘文件系统上运行.

Most version control tools operate on the local disk file system.

大多数关系数据库系统的数据库对象确实存在于文件系统中,因为存在标识对象的文本名称,并且可以使用该名称检索或至少生成创建脚本.

Database objects for most relational database systems do exist in a file system, inasmuch as there is a textual name identifying the object and the creation script can be retrieved or at least generated using this name.

但它不是本地磁盘文件系统,因此它们对于严格在本地磁盘文件系统上运行的 CVS 或 SVN 等工具是不可见的.

But it isn't the local disk file system, and as a result they are invisible to tools like CVS or SVN, which operate strictly on the local disk file system.

要使SVN应用于数据库对象,必须将它们复制到本地磁盘文件系统中,并且必须将本地磁盘文件系统的更改复制到数据库中.

In order for SVN to be applied to database objects, they must be replicated into the local disk file system, and changes to the local disk file system must be replicated to the database.

与源代码不同,源代码每个开发人员都维护一个私人工作副本,开发人员倾向于在网络上某处服务器上的共享数据库上工作.虽然 Visual Studio 为按需装载项目本地数据库副本提供直接支持,但由于没有方便可靠的方法来合并更改,开发人员一直回避此功能.

Unlike source code, of which each developer maintains a private working copy, developers tend to work on a shared database on a server somewhere on the network. While Visual Studio provides direct support for mount-on-demand project-local copies of the database, developers have shunned this facility because there is no convenient and reliable way to merge changes.

但是,一旦对数据库结构的更改由 CVS 或 SVN 等复制合并版本控制系统管理,传播和合并将主要是自动的(条冲突)并且不再有任何理由共享数据库.

However, once changes to the database structure are managed by a copy-merge version control system like CVS or SVN, propagation and merging will be mostly automatic (bar conflicts) and there is no longer any reason to share a database.

Microsoft SQL Management Studio 支持任何实现 SCC 规范的版本控制.微软只列出了 VSS (blech),但谷歌提供了大量的选项.然而,SCC 是关于锁定的——双重漂白.

Microsoft SQL Management Studio supports version control for anything that implements the SCC spec. Microsoft only lists VSS (blech) but Google reveals a plethora of options. However, SCC is all about locking - double blech.

整个问题现在转移到文件系统之间的复制之一.CodePlex 包含 VS2005/SQL2005 的实现,但它不适用于 VS2008/SQL2008.

The whole question now devolves to one of replicating between file systems. CodePlex contains an implementation for VS2005/SQL2005 but it doesn't work with VS2008/SQL2008.

在这一点上,我认为我应该怎么做"的基本问题已经得到令人满意的解决,尽管我不确定如何奖励积分.

At this point I think the underpinning question of "how should I go about this" has been satisfactorily addressed, although I'm not sure how to award points.

感谢所有关注者的意见.

Thank you to all concerned for your input.

确实出现了一些具体问题,主要是关于如何编写各种类型的模式对象的脚本.

Some concrete questions do arise, mostly to do with how to script out various types of schema object.

  • 如何按依赖顺序提取 createalter 脚本
    • 查看
    • 存储过程
    • 功能
    • 触发
    • 索引
    • 外键

    我注意到可以使用策略将操作绑定到架构中的更改.仍然存在依赖关系排序和如何编写表创建语句的问题

    It has come to my attention that it is possible to bind actions to changes in schema using policies. There remain the questions of dependency ordering and of how to script a table creation statement

    推荐答案

    我们使用 Red Gate 将当前模式与存储在 SVN 中的脚本文件进行比较,以获取基线、版本控制等

    We use Red Gate to compare current schema against the scripted files stored in SVN for baselines, versioning etc

    然而,我们的主参考实际上是生产的恢复副本.这是我们的基线,应该对应于 SVN.将主脚本提交到 SVN 是部署过程的一部分,Red Gate 这样做很有用:它只更改已更改对象的文件.

    However, our master reference is actually a restored copy of production. This is our baseline and should correspond to SVN. It's part of deployment process to commit the master scripts to SVN, which Red Gate does usefully: it only changing the files for changed objects.

    我们进一步分离了我们的工作脚本和发布脚本(仅更改),因此我们始终在 SVN 中拥有一个主数据库和一个基线.不过,我们只使用脚本进行开发.

    We further separate our working scripts and release scripts (changes only), so we always have a master DB and a baseline in SVN. We only use scripts for development though.

    数据库源代码控制是个好东西,但由于 SQL Server 对象的性质,它的实施具有挑战性:某些表中的一行或 3...

    Database source control is good stuff, but it's challenging to implement because of the nature of what a SQL Server object is: a row or 3 in some tables...

相关文章