Open OmarHawk opened 2 years ago
@OmarHawk Are you interested in trying to fix this if I assign a bug bounty to it?
@mraible sure, but I will only come to this somewhen next week :-)
I may try to convert the content_type field to an actual field for v8.
So, instead of implementing at templates, we should inject the field to fields list.
Templates won’t need to add all those if blob then generate the content_type field
anymore.
@OmarHawk Are you available to provide a PR?
well, If I'd have more time, definetly. Will check it out somwhen this week maybe, but can't promise anything. The necessary change is minimal tbh.
Overview of the issue
We do have a schema, where there is a column with type AnyBlob in there. The application was initially generated using the --incremental-changelog flag.
The Entity looks initially like this (also can be reproduced with larger schemas of course):
This initial schema looks like this in the liquibase changeset:
Please note the column
content_string_content_type
.After some time, we do want to get rid of the
contentString
field and (possibly) have another (unrelated) field instead, so the schema now looks like this:When we now run the
jhipster jdl demo.jdl
command, it produces a new liquibase changeset, that looks like this:So it drops the Blob column
content_string
itself and adds a varchar columnanother_column
instead. But it doesn't get rid of the helper columncontent_string_content_type
for the Blob, leaving remains in the database that are not needed anymore and lead to a column that is not referenced anywhere anymore.Motivation for or Use Case
Database now contains a column which is not under any control anymore.
Reproduce the error
Create an application with a AnyBlob column in one of the entities. Remove the AnyBlob column and let a changelog be generated.
Related issues
Haven't found any.
Suggest a Fix
Whereever the changesets are generated consider also special data types where one entity field produces more than one column (like AnyBlob).
JHipster Version(s)
7.5.0
JHipster configuration
C:\Users\jwedding\git\markant\demo2>jhipster info INFO! Using JHipster version installed locally in current project's node_modules Welcome to the JHipster Information Sub-Generator
JHipster Version(s)
JHipster configuration, a
.yo-rc.json
file generated in the root folder.yo-rc.json file
JDL for the Entity configuration(s)
entityName.json
files generated in the.jhipster
directoryJDL entity definitions
Environment and Tools
openjdk version "11.0.12" 2021-07-20 LTS OpenJDK Runtime Environment 18.9 (build 11.0.12+7-LTS) OpenJDK 64-Bit Server VM 18.9 (build 11.0.12+7-LTS, mixed mode)
git version 2.34.1.windows.1
node: v14.18.2
npm: 6.14.15
Docker version 20.10.8, build 3967b7d
docker-compose version 1.29.2, build 5becea4c
Entity configuration(s)
entityName.json
files generated in the.jhipster
directoryFinal one after steps have been performed:
Browsers and Operating System
Windows 10