Skip to content
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

New CLI commands: rename-entity and remove-entity #8933

Closed
3 of 5 tasks
murdos opened this issue Dec 8, 2018 · 14 comments
Closed
3 of 5 tasks

New CLI commands: rename-entity and remove-entity #8933

murdos opened this issue Dec 8, 2018 · 14 comments

Comments

@murdos
Copy link
Contributor

murdos commented Dec 8, 2018

Overview of the feature request

rename-entity would rename an existing entity and update all related entities
remove-entity would remove an existing entity only if no other entity is related

Motivation for or Use Case

As a development platform, JHipster should handle the whole possible lifecycle of an entity:

  • create
  • update
  • rename
  • remove

Because you don't always (never?) design your perfect model from beginning, you should have the ability to rename or remove an entity without having to do it manually (it's quite painful).
There's also a common trap: when you rename an entity in your JDL, a new entity is created, but the old one is still here.

Related issues or PR

#4372

  • Checking this box is mandatory (this is just to show you read everything)
@deepu105
Copy link
Member

deepu105 commented Dec 8, 2018 via email

@murdos
Copy link
Contributor Author

murdos commented Dec 8, 2018

Because when I create a new entity for the new name there's now way to make the link with the entity with the former name, and thus all linked entities won't be updated?

entity Category {
    description String required,
}

entity Product {
    title String required,
}

relationship ManyToMany {
	Category{product(title)} to Product{category}
}

What if I want to rename Product to e.g. Asset?
jhipster entity Asset => new entity Asset created
jhipster remove-entity Product => not possible, since Category still references Product

@pascalgrimaud
Copy link
Member

Here my point of view.
JHipster is used for generating code, not for renaming or deleting. If the user did a mistake by choosing a wrong name for his entity, it's on his side, not on our side. JHipster should not be used to fix user's mistake.
For deleting use case, git is the best here.
For renaming, it will took less than 5min, with find / replace, if the user knows well his code.

@murdos
Copy link
Contributor Author

murdos commented Dec 9, 2018

Since that what I've done this week (renaming entities), I can tell that it's not that simple, and it took me way more than 5min.
Now either JHipster is just a tool to bootstrap your application, that you trash away after the application is generated, or it's a development platform that you use while you're developing your application. In the latter case, this requested feature case is very useful.

If the user did a mistake by choosing a wrong name for his entity, it's on his side, not on our side. JHipster should not be used to fix user's mistake.

It's not about mistake. It's about keeping a common, rigorous language between developers and users (of the application). Defining an ubiquitous language can take time, and it can evolve during the project lifecycle.

For deleting use case, git is the best here.

How can you do that when there's hundred of commits after the initial entities generation?

@pascalgrimaud
Copy link
Member

Here a use case:

  • the user creates an application with hundred entities + SQL
  • then, some dev + custom modifications
  • some deployment, so apply liquibase changes
  • the user needs to rename an entity (with table). Do you think he will:
    • do it manually ? (personnaly, I will choose this, helping by git diff)
    • or use this new rename sub generator ? a minor bug in this, and the user will do the change manually (no time to wait the fix / a new release), or he will open a new ticket without details because he can't share his code (exactly like upgrade sub-generator)
  • for both solutions, he'll need to check closely his code, manage liquibase diff, because the rename sub-gen can't handle it

@murdos : I'm not against, just reluctant to have this, because I think it will be hard to achieve (specially to test in our CI), then to maintain and it will probably result in a lot of issues.
But maybe I'm wrong, because I don't use JHipster as a platform, but only to bootstrap my application.

@deepu105
Copy link
Member

deepu105 commented Dec 10, 2018 via email

@jdubois
Copy link
Member

jdubois commented Dec 20, 2018

I agree with the comments from @pascalgrimaud @deepu105 - this is going to be a headache, and will cause many bug reports because people will expect too much from this. There are many limitations on this, and the easier way to rollback a change is just to use Git properly.

I'm closing this because I don't think this should be done.

@jdubois jdubois closed this as completed Dec 20, 2018
@cbornet
Copy link
Member

cbornet commented Dec 20, 2018

I had worked on an entity remover some time ago : #4403.
I gave up because there were problems on Windows (it was working fine on unix)
The principle should still work. I may give it a try again one day.

@cbornet
Copy link
Member

cbornet commented Dec 20, 2018

The branch is still there for someone to work on it. The principle is to use git in the same way the upgrade gen works.

@jdubois jdubois added this to the 5.7.2 milestone Dec 21, 2018
@murdos murdos removed this from the 5.7.2 milestone Dec 23, 2018
@jdubois jdubois added this to the 5.8.0 milestone Jan 25, 2019
@MInesGomes
Copy link

@cbornet @murdos
Is it possible to remove an entity ?
I would love to do that not manually:-)

@deepu105
Copy link
Member

deepu105 commented Jul 14, 2019 via email

@ari62
Copy link

ari62 commented Jul 27, 2022

A tutorial how to remove an entity across Java / Angular would be great, the IDE Safe Delete refactoring just warns you about unsafe occurrences.

@Ahrovan
Copy link

Ahrovan commented Apr 27, 2024

@murdos Update this issues please

@mshima
Copy link
Member

mshima commented Apr 27, 2024

@Ahrovan it’s not implemented.
It’s not planned.
If someone wants to contribute with an implementation we can happily review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants