惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Help Net Security
Help Net Security
量子位
大猫的无限游戏
大猫的无限游戏
雷峰网
雷峰网
B
Blog RSS Feed
宝玉的分享
宝玉的分享
Security Latest
Security Latest
小众软件
小众软件
P
Proofpoint News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
月光博客
月光博客
博客园_首页
美团技术团队
T
Tailwind CSS Blog
The Cloudflare Blog
爱范儿
爱范儿
L
LINUX DO - 热门话题
酷 壳 – CoolShell
酷 壳 – CoolShell
T
Threatpost
V
Vulnerabilities – Threatpost
A
Arctic Wolf
C
Cybersecurity and Infrastructure Security Agency CISA
S
Securelist
阮一峰的网络日志
阮一峰的网络日志
T
Tenable Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
J
Java Code Geeks
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
Schneier on Security
I
Intezer
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
腾讯CDC
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Scott Helme
Scott Helme
S
SegmentFault 最新的问题
Simon Willison's Weblog
Simon Willison's Weblog
人人都是产品经理
人人都是产品经理
Schneier on Security
Schneier on Security
Jina AI
Jina AI
N
News and Events Feed by Topic
C
Cisco Blogs
L
Lohrmann on Cybersecurity
V
V2EX
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Cisco Talos Blog
Cisco Talos Blog
W
WeLiveSecurity
The Last Watchdog
The Last Watchdog
O
OpenAI News
V
Visual Studio Blog
Apple Machine Learning Research
Apple Machine Learning Research

博客园 - Zealic

Windows 下使用 Nginx+Mono 部署 ASP.Net Visual Studio 使用的 ProjectTypeGuids MSBuild 简解 CCNet 的 Build 流程 发散性碎片(2008-12-29) Google Toolbar 5 简析 Google Gadget 的数据丢失原因 乱弹用户资源 职业·病 SVN 简单备份与还原 发散性碎片(2008-11-14) 动态链接库重定向技术 SilverLight 与移动平台 Linux 下的 Apache + FastCGI 部署 ROR 应用 Live Writer 12.0.1370.325 + SyntaxColor4Writer 0.27 ICE 编译器环境集合 Subversion and .Net Windows 下的 Apache + FastCGI 部署 ROR 应用 好用的 Abyss Web Server
一种版本化的数据库脚本管理机制
Zealic · 2009-07-29 · via 博客园 - Zealic

  现今开发的软件当中,多数系统的数据都是基于数据库存储的,但是由于软件变化的复杂性,相对于维护代码,数据库架构的版本并不是那么好维护。

  这里本人针对实际情况,理想化出一种可以清晰理解的数据库架构脚本的版本控制机制。

  请先看目录树:

Example.DataSchema
├─V1.0
│  ├─Common
│  │      001.Create.Table.Product.sql
│  │      002.Create.Table.User.sql
│  │      003.Create.Table.Feedback.sql
│  │      004.Create.Table.Role.sql
│  │      005.Create.Function.FN_GetlProductCode.sql
│  │      006.Create.Function.USP_CleanFeedback.sql
│  │
│  ├─Enterprise
│  │      001.Create.Table.Highland.sql
│  │
│  └─Professional
│          001.Create.Table.Lowend.sql

├─V1.1
│  ├─Common
│  │      001.Alter.Table.User.sql
│  │      002.Alter.Function.FN_GetlProductCode.sql
│  │      003.Drop.Function.USP_CleanFeedback.sql
│  │
│  ├─Enterprise
│  │      001.Alter.Table.Highland.sql
│  │
│  └─Professional
│          001.Alter.Table.Lowend.sql

└─V2.0
    ├─Common
    │      001.Alter.Table.Product.sql
    │      002.Alter.Table.User.sql
    │      003.Create.Function.USP_CheckProduct.sql
    │
    ├─Enterprise
    │      001.Create.Table.Overland.sql
    │
    └─Professional
            001.Alter.Table.Lowland.sql
            002.Create.Table.Notebook.sql

  相信上面的目录结构还算明了,我们可以根据软件的版本追溯数据库,而不是通过版本控制工具来追溯原始数据库,而数字序号的前缀,更指明了脚本执行顺序,再也不用因为在建立数据库时受到依赖/外键关系的原因而运行脚本失败了。整个层次非常清晰,头脑通透的 Coder 相信可以一看便明了。

  版本目录下有三个文件夹:Common, Professional, Enterprise,分别代表一个产品的三个定制化版本,因为软件中可能有这样的需求,软件基本结构不变,但是使用提供者模式提供了多个定制化版本,每个提供者的数据库结构基本相同,但是又有极少的差异。通过上面的这种管理机制,可以避免在源代码控制系统中开分支来维护,从某种程度上来说,提高了一定的可维护性。

  这种管理机制类似于 ROR,不过 ROR 更 OO 一些,还能够隔离特定数据;通过这种机制,我们可以结合 RikMigrations 或 Migrator.NET 进行自动化的数据库升级(需要编码)。

2009-07-29 Zealic