-
-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add posibility to upgrade generated database #98
Comments
@sergrdz As you said before EF already provide the migration tool. Do you want the generator to do it automatically when an entity was generated ? |
That's right, in the first generation of the application run the tool, and in subsequent changes to the model. In the current version, if changes are made to the model, they are not automatically added to the database. So the changes have to be added in another way. |
We can do that, but i think the user must be able to choose when the migration is created so i propose you to ask if the generator add migration after entity creation with this the user can create multiple entity and create migration on the last entity.What do you think about this ? I work currently on issues for milestone 1.0.0. Feel free to you submit a PR if you are interested by this fonctionality |
I think it's a good idea. But when entities are generated with the command "import-jdl", I can't find a way to know which is the end of generation to invoke generation of migration. The java version generates the changes in different ways, we could do it that way, always create the migration when using the entity generator. |
Yes, it's good remarks. So, yes we could generate migration when using entity generator. |
The java generator actually generates the liquibase migrations itself using templates, but since in dotnet we have the dotnet ef tool that automatically generates them I think using it is the way to go because it is just a simple command with one line. I have added some documentation to the readme.md on how to use entity framework database migrations but it is still a manual job to run the dotnet ef command. Is there any way to know when entity generation is finished, so we can automatically run the dotnet ef commands to generate the migrations? |
For the jdl the better place is in https://github.com/jhipster/generator-jhipster/blob/master/cli/import-jdl.js For generation after entity generation with cli we can add command here (https://github.com/jhipster/jhipster-dotnetcore/blob/master/generators/entity/index.js) and add a boolean in prompt.js for ask user about migration |
Not sure but looks like you want something like this at the blueprint main generator:
If it's optional then you can add a prompt or option |
@mshima thanks for your answer. I think your code work for one entity (like with entity generation with cli). The idea is to call this code only once after jdl generation rather than one per entity and i don't know if it is possible in the blueprint to add one callback after jdl generation. |
Not sure why you think so. There is no easy way to add a custom callback to jdl generation, only if you override jhipster import-jdl/jdl command. The only callback is the jhipster main generator, which is called like |
Ah yes I hadn't thought about the app script. I think it's a good solution. Thank you very much for your advice @mshima |
There is the Migrations Bundle Feature dotnet/efcore#19693 that will probably be released with EF Core 6 that might be helpful. |
It would be good if Liquibase was used for deploying DB schema and also for unit-testing. |
Like the jhipster version for java, it uses liquibase to generate changes in the database. It would be nice to add this feature.
EntityFramework does it using "dotnet ef migrations add Update_1"
The text was updated successfully, but these errors were encountered: