Skip to content
This repository has been archived by the owner on Mar 21, 2021. It is now read-only.

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

Open
1 task done
62mkv opened this issue Jul 7, 2020 · 14 comments
Open
1 task done

Comments

@62mkv
Copy link

62mkv commented Jul 7, 2020

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
  • Checking this box is mandatory (this is just to show you read everything)
@62mkv
Copy link
Author

62mkv commented Jul 7, 2020

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

@62mkv 62mkv changed the title add option for entities pre-existing DB tables (when no Liquibase migration is required) add option for entities for pre-existing DB tables (when no Liquibase migration is required) Jul 7, 2020
@MathieuAA
Copy link
Member

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
Copy link
Author

62mkv commented Jul 7, 2020

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

can you move the issue too ?

@MathieuAA
Copy link
Member

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

@MathieuAA
Copy link
Member

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

@mshima
Copy link
Member

mshima commented Jul 7, 2020

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
Copy link
Author

62mkv commented Jul 7, 2020 via email

@mshima
Copy link
Member

mshima commented Jul 7, 2020

Yep, IFAIK decorators is only supported by entities.

@skipDbChangelog
entity Foo {}

@MathieuAA
Copy link
Member

Also supported for fields, rels too

@mshima
Copy link
Member

mshima commented Jul 7, 2020

Also supported for fields, rels too

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

@62mkv
Copy link
Author

62mkv commented Jul 8, 2020

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
Copy link
Member

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

@62mkv
Copy link
Author

62mkv commented Jul 9, 2020

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
Copy link
Author

62mkv commented Jul 9, 2020

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

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

No branches or pull requests

3 participants