jhipster-core icon indicating copy to clipboard operation
jhipster-core copied to clipboard

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

Open 62mkv opened this issue 5 years ago • 14 comments
trafficstars

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
  • [x] Checking this box is mandatory (this is just to show you read everything)

62mkv avatar Jul 07 '20 09:07 62mkv

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

62mkv avatar Jul 07 '20 09:07 62mkv

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

MathieuAA avatar Jul 07 '20 10:07 MathieuAA

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

can you move the issue too ?

62mkv avatar Jul 07 '20 10:07 62mkv

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

MathieuAA avatar Jul 07 '20 11:07 MathieuAA

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

MathieuAA avatar Jul 07 '20 13:07 MathieuAA

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.

mshima avatar Jul 07 '20 14:07 mshima

Can this be done per entity?

Sent from Mail.ru app for Android Tuesday, 07 July 2020, 05:28PM +03:00 from Marcelo Shima [email protected] :

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 .

62mkv avatar Jul 07 '20 14:07 62mkv

Yep, IFAIK decorators is only supported by entities.

@skipDbChangelog
entity Foo {}

mshima avatar Jul 07 '20 14:07 mshima

Also supported for fields, rels too

MathieuAA avatar Jul 07 '20 20:07 MathieuAA

Also supported for fields, rels too

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

mshima avatar Jul 07 '20 21:07 mshima

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

62mkv avatar Jul 08 '20 12:07 62mkv

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

MathieuAA avatar Jul 08 '20 16:07 MathieuAA

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 avatar Jul 09 '20 08:07 62mkv

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

62mkv avatar Jul 09 '20 12:07 62mkv