Replies: 4 comments 4 replies
-
Hello @Incanus3, as far as I remember, renaming is a pain and at least not supprted by all platforms. (depending on platform, you have to remove indices/constraints, do rename and recreate indices afterwards) We avoid renames whenever it is possible, but there is a simple workaround: Just rename the field in java. Ebean will create the new column and drop the old (in two migration steps) |
Beta Was this translation helpful? Give feedback.
-
Hi @rPraml and thanks for the reply. Well, in our case, there are no indices, nor constraints on this column, so a simple Allow me a different question then: if I were to create the xml manually, is there a way to generate the sql files for it? Because currently if the model.xml file is there (even if it was generated by |
Beta Was this translation helpful? Give feedback.
-
Migrations that would Rename a table or column are not automatically generated. For 2 reasons:
So if you want to do RENAME migrations we want people to understand that they are "Breaking migrations" and that they need to do that via scheduling downtime / stopping the application etc. So yes, you need to do this "By Hand" [manually] and I deem that a good approach because it means you are explicitly opting in to a "Breaking change" / scheduled downtime / stopping the application style migration. |
Beta Was this translation helpful? Give feedback.
-
hi @rbygrave. yeah, this makes perfect sense and I have no problem with that. I just thought it would be nice to do the manual work in the xml, which is backend agnostic, and then generate the sql files from that. |
Beta Was this translation helpful? Give feedback.
-
Hi guys,
we just started using ebean-migrations a week back and were mostly successful (we did encounter two minor issues which I reported here). The only thing we weren't able to get working are rename migrations. I looked (briefly, since I don't understand all the details) over the code in
ebean-migration
andebean-ddl-generator
and found that that there is indeed aRenameColumn
class which is supported byModelContainer.applyChangeSet()
andMTable.apply()
and there's even a test migration6.0__renameColumn.model.xml
applied byModelContainerTest.apply_renameColumn()
, but I can't find a way to generate this kind of migration. Could you please offer some hints as for how this can be done?BTW, I also tried a semi-manual approach - make the change in model, run
DbMigration.generateMigration()
which generates drop+create, delete the generated sql files if any (in my case it didn't generate any because the column is not nullable and we don't specifyDbDefault
), update the XML as followsand rerun
generateMigration()
hoping that it will see that the sql files for the version are missing and finish generating them, but it just reportsDbMigration> no changes detected - no migration written
.Cheers
Beta Was this translation helpful? Give feedback.
All reactions