jhipster / jhipster-core

JHipster Domain Language, used by JHipster UML and JDL-Studio to generate entities
Apache License 2.0
346 stars 116 forks source link

add option for entities for pre-existing DB tables (when no Liquibase migration is required) #474

Open 62mkv opened 4 years ago

62mkv commented 4 years ago
Overview of the feature request

Want to have a way to define JH entities without defining Liquibase migrations.

For example, having unary option "external" (or "existing") could be used for that.

Motivation for or Use Case

There's a use case to use JHipster to generate simple CRUD UI for pre-existing database tables. Although it's relatively easy to just delete migrations after they've been defined, this feature would improve user experience

Related issues or PR
62mkv commented 4 years ago

I could give it a go, if with some guidance (I would assume not only this project should be affected)

MathieuAA commented 4 years ago

Hello there. JCore's code has moved to the generator. If you wanna start working on it, I suggest working on the generator's master branch

62mkv commented 4 years ago

oops. so this is archived? haven't noticed..

can you move the issue too ?

MathieuAA commented 4 years ago

Not yet archived, we're waiting for v7 to be released before doing anything meaningful

MathieuAA commented 4 years ago

For now, we're keeping the issues here and we'll move them later.

mshima commented 4 years ago

Not sure an official definition is required for this use case, seems too specific to me.

Can be easily implemented by @skipDbChangelog and adding || fileData.skipDbChangelog to https://github.com/jhipster/generator-jhipster/blob/5f87d2a235854eeafc9e399efad67126b45515b8/generators/entity/index.js#L204.

62mkv commented 4 years ago

Can this be done per entity?

Sent from Mail.ru app for Android Tuesday, 07 July 2020, 05:28PM +03:00 from Marcelo Shima notifications@github.com :

Not sure an official definition is required for this use case, seems too specific to me. Can be easily implemented by @skipDbChangelog and adding || fileData.skipDbChangelog to https://github.com/jhipster/generator-jhipster/blob/5f87d2a235854eeafc9e399efad67126b45515b8/generators/entity/index.js#L204 . — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub , or unsubscribe .

mshima commented 4 years ago

Yep, IFAIK decorators is only supported by entities.

@skipDbChangelog
entity Foo {}
MathieuAA commented 4 years ago

Also supported for fields, rels too

mshima commented 4 years ago

Also supported for fields, rels too

My bad I wanted to say not supported for application/config.

62mkv commented 4 years ago

so, is this suggested to implement by adding a new unary option, or is it existing one? I can't find it mentioned here: https://www.jhipster.tech/jdl/options#available-options

MathieuAA commented 4 years ago

This should be a new option. Something like "external" on an entity speaks for itself, so that can be used

62mkv commented 4 years ago

turned out it's not as simple as "not generate migrations for those entities". all integration tests are failing now, as in the test Db these tables (obviuosly) are not present. Looking into it now, but any suggestions are welcome.

and the tests are failing because of:

Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table [entity-name]
62mkv commented 4 years ago

I was able to walk this around by still creating those migrations but providing context="test" for them.