我倾向于使用'迁移'脚本,这是从简单的版本化脚本开始的下一个阶段。通过迁移,您可以指定对数据库所做的更改(添加,删除等)以及如何撤消迁移正在执行的更改。然后用一个不会与其他开发人员冲突的某种形式的版本标记。一个特别好的版本号是当前时间(以YYYYMMDDHHMMSS格式或者距离纪元秒)。这是一个不错的选择,因为您不太可能发生版本冲突,并且由于此类时间戳的严格增长性质,仍然很容易发现是否存在新版本。
注意:这受到Rails中的迁移系统的很大影响。对于更多细节和想法,我强烈建议查看该系统。
的Rails迁移:
class CreateGroups < ActiveRecord::Migration
def self.up
create_table :groups do |t|
t.string :name
t.references :owner
t.timestamps
end
end
def self.down
drop_table :groups
end
end
主义迁移:
class CreateGroups extends Doctrine_Migration
{
public function up()
{
// Create new author table
$columns = array('id' => array('type' => 'integer',
'length' => 4,
'autoincrement' => true),
'name' => array('type' => 'string',
'length' => 255),
'owner_id' => array('type' => 'integer',
'length' => 4));
$this->createTable('groups', $columns, array('primary' => array('id')));
}
public function down()
{
$this->dropTable('groups');
}
}
(对不起,缺乏学说时间戳的......在轨道中的时间戳呼叫created_at和的updated_at字段的表补充说,是自动为你管理的,我不确定在教条中有类似的行为,所以我把它们排除在外)。
如果我不仅限于1人,我会赞成18次:D – whaley 2009-10-28 17:41:33
让你的奶奶投票然后:)更严肃地说,很高兴你觉得它有帮助。 – 2009-10-28 17:52:55
感谢您的链接。希望3条规则中的项目#1有更多细节。它是我们现在正在努力的东西。说起来容易做起来难。 – CodingWithSpike 2009-10-28 18:20:43