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.49k stars 4.02k forks source link

Add support to modifyDataType for entity type changes #26404

Open flyliu33 opened 3 months ago

flyliu33 commented 3 months ago
Overview of the issue

Executing jhipster jdl .\road-parking.jdl --incremental-changelog after changing entity UserExtended.phoneNumber from String to Integer. Everything works well but Change log of modifying column, modifyDataType tag , cannot be created automatically.

Motivation for or Use Case
Reproduce the error

orginal jdl

` entity Role { name String required maxlength(10) type RoleType isEnabled Boolean }

enum RoleType{ ADMIN, USER, MANAGER }

entity Permission { name String description String url String isEnabled Boolean } entity UserExtended{ phoneNumber String sex Sex }

enum Sex{ MALE, FEMALE, OTHER }

relationship ManyToOne{ Role{permission} to Permission }

relationship OneToOne{ UserExtended{user(login)} to User with builtInEntity }

service all with serviceImpl `

modified jdl

` entity Role { name String required maxlength(10) type RoleType isEnabled Boolean }

enum RoleType{ ADMIN, USER, MANAGER }

entity Permission { name String url String isEnabled Boolean } entity UserExtended{ phoneNumber Integer nickName String sex Sex }

entity Friend{ firstName String lastName String sex Sex age Integer }

enum Sex{ MALE, FEMALE, OTHER }

relationship ManyToOne{ Role{permission} to Permission Friend{UserExtended} to UserExtended }

relationship OneToOne{ UserExtended{user(login)} to User with builtInEntity }

service all with serviceImpl `

execute the following comand

jhipster jdl .\road-parking.jdl --incremental-changelog

Related issues
Suggest a Fix
JHipster Version(s)

`jhipster info WARNING! Since JHipster v8, the jhipster command will not use the locally installed generator-jhipster. If you want to execute the locally installed generator-jhipster, run: npx jhipster

    ██╗ ██╗   ██╗ ████████╗ ███████╗   ██████╗ ████████╗ ████████╗ ███████╗
    ██║ ██║   ██║ ╚══██╔══╝ ██╔═══██╗ ██╔════╝ ╚══██╔══╝ ██╔═════╝ ██╔═══██╗
    ██║ ████████║    ██║    ███████╔╝ ╚█████╗     ██║    ██████╗   ███████╔╝

██╗ ██║ ██╔═══██║ ██║ ██╔════╝ ╚═══██╗ ██║ ██╔═══╝ ██╔══██║ ╚██████╔╝ ██║ ██║ ████████╗ ██║ ██████╔╝ ██║ ████████╗ ██║ ╚██╗ ╚═════╝ ╚═╝ ╚═╝ ╚═══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══════╝ ╚═╝ ╚═╝ https://www.jhipster.tech Welcome to JHipster v8.5.0

Welcome to the JHipster Information Sub-Generator

road-parking@0.0.0 C:\workspace\bi\road-parking
`-- generator-jhipster@8.5.0
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "applicationType": "monolith",
    "authenticationType": "jwt",
    "baseName": "roadParking",
    "buildTool": "maven",
    "cacheProvider": "ehcache",
    "clientFramework": "vue",
    "clientTestFrameworks": [
      "cypress"
    ],
    "clientTheme": "none",
    "creationTimestamp": 1717723305879,
    "cypressAudit": true,
    "cypressCoverage": null,
    "databaseType": "sql",
    "devDatabaseType": "postgresql",
    "devServerPort": 9060,
    "enableHibernateCache": true,
    "enableSwaggerCodegen": true,
    "enableTranslation": true,
    "entities": [
      "Role",
      "Permission",
      "UserExtended"
    ],
    "feignClient": null,
    "incrementalChangelog": true,
    "jhipsterVersion": "8.5.0",
    "languages": [
      "zh-cn",
      "en"
    ],
    "lastLiquibaseTimestamp": 1718097829000,
    "messageBroker": false,
    "microfrontend": null,
    "microfrontends": [],
    "nativeLanguage": "zh-cn",
    "packageName": "com.jlzn.road",
    "prodDatabaseType": "postgresql",
    "reactive": false,
    "searchEngine": false,
    "serverPort": null,
    "serverSideOptions": [
      "websocket:spring-websocket",
      "enableSwaggerCodegen:true"
    ],
    "serviceDiscoveryType": false,
    "syncUserWithIdp": null,
    "testFrameworks": [
      "cucumber",
      "cypress"
    ],
    "websocket": "spring-websocket",
    "withAdminUi": true
  }
}
Environment and Tools

openjdk version "21.0.2" 2024-01-16 OpenJDK Runtime Environment (build 21.0.2+13-58) OpenJDK 64-Bit Server VM (build 21.0.2+13-58, mixed mode, sharing)

git version 2.45.1.windows.1

node: v20.13.1 npm: 10.5.2

Docker version 26.0.0, build 2ae903e

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions
entity Friend {
  firstName String
  lastName String
  sex Sex
  age Integer
}
@ChangelogDate("20240607072345")
entity Role {
  name String required maxlength(10)
  type RoleType
  isEnabled Boolean
}
@ChangelogDate("20240607072346")
entity Permission {
  name String
  url String
  isEnabled Boolean
}
@ChangelogDate("20240607072347")
entity UserExtended {
  phoneNumber Integer
  nickName String
  sex Sex
}

enum Sex {
  MALE,
  FEMALE,
  OTHER
}
enum RoleType {
  ADMIN,
  USER,
  MANAGER
}

relationship OneToOne {
  UserExtended{user(login)} to User with builtInEntity
}
relationship ManyToOne {
  Friend{userExtended} to UserExtended
  Role{permission} to Permission
}

service Friend, Role, Permission, UserExtended with serviceImpl
search Role, Permission, UserExtended with no

Congratulations, JHipster execution is complete! If you find JHipster useful consider sponsoring the project https://www.jhipster.tech/sponsors/

Thanks for using JHipster!`

JHipster configuration
Entity configuration(s) entityName.json files generated in the .jhipster directory

Friend.json Permission.json Role.json UserExtended.json

Browsers and Operating System
mshima commented 3 months ago

Only add/remove field is supported. Field rename and field attributes change are not supported.

There is no plan to support.

flyliu33 commented 3 months ago

Only add/remove field is supported. Field rename and field attributes change are not supported.

There is no plan to support.

BTW, this following command cannot create modified column either: ./mvnw compile liquibase:diff

I consider if this feature should also be a basic feature for maintaining database. Field rename and field attributes change might be a high frequent behavior at development stage. I am not sure, but thanks so much.