jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.53k stars 4.02k forks source link

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

Closed murdos closed 5 years ago

murdos commented 5 years ago
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:

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

deepu105 commented 5 years ago

Why would you need rename if you have remove and add?

On Sat, 8 Dec 2018, 11:07 am Aurélien Mino <notifications@github.com wrote:

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 https://github.com/jhipster/generator-jhipster/issues/4372

  • Checking this box is mandatory (this is just to show you read everything)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jhipster/generator-jhipster/issues/8933, or mute the thread https://github.com/notifications/unsubscribe-auth/ABDlF-L1Rxto_BaC1KexWxSqRDCQj2bKks5u249TgaJpZM4ZJkRc .

murdos commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

Here a use case:

@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 commented 5 years ago

Personally, I will also be against renaming entity with JH as it will bring a lot of maintenance overhead for us, and the only way to do it properly would be to use a lot of regex/needles etc which is not very scalable and is too much work. An IDE can do the job much better IMO. For deletion I'm half minded

Thanks & Regards, Deepu

On Sun, Dec 9, 2018 at 12:49 PM Pascal Grimaud notifications@github.com wrote:

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 https://github.com/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.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jhipster/generator-jhipster/issues/8933#issuecomment-445530707, or mute the thread https://github.com/notifications/unsubscribe-auth/ABDlF9MN-76-_Nzbx55nZQnu0AxxtrQHks5u3PjjgaJpZM4ZJkRc .

jdubois commented 5 years ago

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.

cbornet commented 5 years ago

I had worked on an entity remover some time ago : https://github.com/jhipster/generator-jhipster/pull/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 commented 5 years ago

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.

MInesGomes commented 5 years ago

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

deepu105 commented 5 years ago

Please use your IDE for that. We will not be doing this as it is too much maintenance overhead for us for very little value.

On Fri, 12 Jul 2019, 2:58 pm Ines Gomes, notifications@github.com wrote:

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

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jhipster/generator-jhipster/issues/8933?email_source=notifications&email_token=AAIOKFY55PQY7PZOHTQ34QLP7B5WZA5CNFSM4GJGIROKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZZVX3A#issuecomment-510876652, or mute the thread https://github.com/notifications/unsubscribe-auth/AAIOKF5M7QRBUYBQ7SSDVTTP7B5WZANCNFSM4GJGIROA .

ari62 commented 2 years ago

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 commented 5 months ago

@murdos Update this issues please

mshima commented 5 months ago

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