迁移文件中的所有额外垃圾是怎么回事?
我今天开始测试 grails 数据库迁移插件。我与域进行了初始同步,然后基于运行 diff 命令创建了新的更改日志。这应该像重命名列并向该列(重新)分配索引一样简单。所以我希望看到以下内容……
changeSet(author: "gdboling (generated)", id: "1306242441630-1") {
addColumn(tableName: "manuscript_review_reviewer") {
column(name: "reviewer_id", type: "bigint") {
constraints(nullable: "false")
}
}
}
changeSet(author: "gdboling (generated)", id: "1306242441630-2") {
addPrimaryKey(columnNames: "manuscript_review_id, reviewer_id", constraintName: "manuscript_rePK", tableName: "manuscript_review_reviewer")
}
changeSet(author: "gdboling (generated)", id: "1306242441630-3") {
dropPrimaryKey(tableName: "manuscript_review_reviewer")
}
changeSet(author: "gdboling (generated)", id: "1306242441630-4") {
dropForeignKeyConstraint(baseTableName: "manuscript_review_reviewer", baseTableSchemaName: "manning_main_dev", constraintName: "FK9BEFBBB34863C659")
}
changeSet(author: "gdboling (generated)", id: "1306242441630-179") {
addForeignKeyConstraint(baseColumnNames: "reviewer_id", baseTableName: "manuscript_review_reviewer", constraintName: "FK9BEFBBB3A28B41DF", deferrable: "false", initiallyDeferred: "false", referencedColumnNames: "id", referencedTableName: "user", referencesUniqueColumn: "false")
}
changeSet(author: "gdboling (generated)", id: "1306242441630-212") {
dropColumn(columnName: "user_id", tableName: "manuscript_review_reviewer")
}
一切都很好。但是,我还看到很多与我的更改无关的 dropIndex 和 createIndex 块。有谁知道为什么会出现这种情况?
I started testing out the grails database-migration plugin today. I did an initial sync with the domain and then created a new changelog based on running the diff command. This should have been as simple as renaming a column and (re)assigning the index to that column. So I expect to see the following...
changeSet(author: "gdboling (generated)", id: "1306242441630-1") {
addColumn(tableName: "manuscript_review_reviewer") {
column(name: "reviewer_id", type: "bigint") {
constraints(nullable: "false")
}
}
}
changeSet(author: "gdboling (generated)", id: "1306242441630-2") {
addPrimaryKey(columnNames: "manuscript_review_id, reviewer_id", constraintName: "manuscript_rePK", tableName: "manuscript_review_reviewer")
}
changeSet(author: "gdboling (generated)", id: "1306242441630-3") {
dropPrimaryKey(tableName: "manuscript_review_reviewer")
}
changeSet(author: "gdboling (generated)", id: "1306242441630-4") {
dropForeignKeyConstraint(baseTableName: "manuscript_review_reviewer", baseTableSchemaName: "manning_main_dev", constraintName: "FK9BEFBBB34863C659")
}
changeSet(author: "gdboling (generated)", id: "1306242441630-179") {
addForeignKeyConstraint(baseColumnNames: "reviewer_id", baseTableName: "manuscript_review_reviewer", constraintName: "FK9BEFBBB3A28B41DF", deferrable: "false", initiallyDeferred: "false", referencedColumnNames: "id", referencedTableName: "user", referencesUniqueColumn: "false")
}
changeSet(author: "gdboling (generated)", id: "1306242441630-212") {
dropColumn(columnName: "user_id", tableName: "manuscript_review_reviewer")
}
All that is well and good. However, I'm also seeing a lot of dropIndex and createIndex blocks that have nothing to do with my change. Anyone know why this would be the case?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 http://jira.grails.org/browse/GPDATABASEMIGRATION 上写一个问题,其中包含以下信息:重现(数据库供应商,最好是一些代码和您的数据库模式),我将看看可以做什么。最坏的情况是您需要将多个元素折叠为一个元素 - 这对于自动化来说是一件棘手的事情,通常需要一些人工干预。
Write up an issue at http://jira.grails.org/browse/GPDATABASEMIGRATION with information to reproduce (database vendor and ideally some code and your database schema) and I'll see what can be done. Worst-case scenario is you'll need to collapse multiple elements into one - this is tricky stuff to automate and usually some human intervention is required.