Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

command jhipster jdl ..\order\src\main\jdl\order.jdl would drop id column of tables #27646

Closed
1 task done
flyliu33 opened this issue Oct 22, 2024 · 3 comments
Closed
1 task done

Comments

@flyliu33
Copy link

flyliu33 commented Oct 22, 2024

Overview of the issue
  1. command jhipster jdl ..\order\src\main\jdl\order.jdl would drop id column of tables

no error threw

Motivation for or Use Case

I try to use command jhipster jdl ..\order\src\main\jdl\order.jdl for generating liquibase. but it will create drop id changelog after modifying my jdl files. so I prefer to use jhipster jdl ..\order\src\main\jdl\order.jdl --skip-db-changelog for generating backend code and then using ./mvnw compile liquibase:diff for generating liquibase changelog, though it doesn't seem more reasonable.

Reproduce the error
  1. generating liquibase changelog by command jhipster jdl
  2. run the backend application and create a table
  3. stop the backend application
  4. modify the jdl file
  5. regenerating by command jhipster jdl
Related issues
Suggest a Fix
JHipster Version(s)

8.7.1

JHipster configuration

To provide all information we need, you should run jhipster info in the project root folder (or workspaces root for microservices), and
copy/paste the result here.
jhipster info removes sentitive information like rememberKey, jwtSecretKey. Double check if there is any other sensitive info.

As alternative you can add a JDL wrapped in below structure

.yo-rc.json file
{
  "generator-jhipster": {
    "applicationType": "microservice",
    "authenticationType": "jwt",
    "baseName": "order",
    "buildTool": "maven",
    "cacheProvider": "redis",
    "clientFramework": "no",
    "clientTestFrameworks": null,
    "clientTheme": null,
    "creationTimestamp": 1726891146771,
    "databaseType": "sql",
    "devDatabaseType": "mysql",
    "enableHibernateCache": true,
    "enableSwaggerCodegen": true,
    "enableTranslation": false,
    "entities": [
      "Company",
      "Order",
      "ParkingLot"
    ],
    "feignClient": true,
    "incrementalChangelog": true,
    "jhipsterVersion": "8.7.1",
    "lastLiquibaseTimestamp": 1729478625000,
    "messageBroker": "kafka",
    "microfrontend": null,
    "microfrontends": [],
    "nativeLanguage": "zh-cn",
    "packageName": "com.pu.order",
    "prodDatabaseType": "mysql",
    "reactive": false,
    "searchEngine": false,
    "serverPort": "8082",
    "serverSideOptions": [
      "messageBroker:kafka",
      "enableSwaggerCodegen:true"
    ],
    "serviceDiscoveryType": "consul",
    "skipClient": true,
    "skipUserManagement": true,
    "syncUserWithIdp": null,
    "testFrameworks": [
      "gatling"
    ],
    "websocket": false,
    "withAdminUi": null
  }
}
Environment and Tools

openjdk version "17.0.12" 2024-07-16 LTS
OpenJDK Runtime Environment Corretto-17.0.12.7.1 (build 17.0.12+7-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.12.7.1 (build 17.0.12+7-LTS, mixed mode, sharing)

git version 2.45.1.windows.1

node: v20.17.0
npm: 10.8.2

Docker version 27.1.1, build 6312585

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions
/**
 * Company
 */
@ChangelogDate("20241018060451")
entity Company {
  id UUID
  name String
  contact String
}

/**
 * Order
 */
@ChangelogDate("20241018060452")
entity Order (jhi_order) {
  id UUID
  /**
   * Parking type, 0: Street parking, 1: Gated parking
   */
  parkType ParkType required
  /**
   * Order number
   */
  orderNo String required maxlength(32)
  /**
   * Stall number, required when parkType=0
   */
  stallNo String maxlength(32)
  /**
   * License plate number, format like [粤S12345] or new energy [粤S123456]
   */
  licensePlate String required maxlength(8)
  /**
   * Order amount in cents
   */
  orderAmount Long required min(1)
  /**
   * Multiple image files, supports jpg, jpeg and png, max 10M per file
   */
  file String
  /**
   * Entry/exit lane code, choose between this and license plate number
   */
  laneNo String maxlength(32)
  /**
   * Platform transaction order number, linking multiple merchant orders
   */
  dealNo String maxlength(32)
  /**
   * Customer number
   */
  customerNo String maxlength(32)
  /**
   * Actual amount received in cents
   */
  realAmount Long min(1)
  /**
   * Platform service fee in cents
   */
  platformFee Long min(1)
  /**
   * Assistance service fee in cents
   */
  assistFee Long min(1)
  /**
   * Payment status, 0: Unpaid, 1: Payment successful, 2: Payment failed
   */
  payState PayState required
  /**
   * Platform order number
   */
  platformNo String maxlength(15)
  /**
   * Creation time
   */
  createTime LocalDate
  /**
   * Entry time
   */
  entryTime LocalDate
  /**
   * Payment time
   */
  payTime LocalDate
  /**
   * Exit deadline
   */
  exitDeadline LocalDate
  /**
   * Exit time
   */
  exitTime LocalDate
}

/**
 * Parking Lot
 */
@ChangelogDate("20241018060453")
entity ParkingLot {
  id UUID
  parkNo String
  name String
  capacity Integer
}

enum ParkType {
  ROAD,
  ENCLOSE
}

enum PayState {
  UNPAY,
  PAYED,
  FAILED
}

relationship OneToMany {
  /**
   * Creditor company
   */
  Company{company} to Order{company}
  /**
   * Assisting company
   */
  Company{assistCompany} to Order{assistCompany}
  /**
   * Parking lot
   */
  ParkingLot{order} to Order{parkingLot}
}

paginate Company, Order, ParkingLot with infinite-scroll
search Company, Order, ParkingLot with no
microservice Company, Order, ParkingLot with Order
clientRootFolder Company, Order, ParkingLot with Order

The information is mandatory for bug reports. This will allow us to use automated tests and genarate the broken sample using jhipster from-issue command.

Browsers and Operating System

Edition Windows 11 Pro
Version 23H2
Installed on ‎8/‎19/‎2024
OS build 22631.4317
Experience Windows Feature Experience Pack 1000.22700.1041.0

  • Checking this box is mandatory (this is just to show you read everything)
@mshima
Copy link
Member

mshima commented Oct 22, 2024

You have incrementalChangelog enabled which generates new changelogs on jdl changes.
You can disable using --no-incremental-changelog.

@flyliu33
Copy link
Author

Thanks for correct, but jhipster jdl order.jdl still will generate the drop id changelog after modifying order.jdl

<?xml version="1.0" encoding="utf-8"?>
<databaseChangeLog
    xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
    xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd
                        http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">

    <!--
        Dropped columns to the entity Company.
    -->
    <changeSet id="20241023090337-1-drop-columns" author="jhipster">
        <dropColumn tableName="company">
            <column name="id"/>
        </dropColumn>
    </changeSet>

    <!-- jhipster-needle-liquibase-add-changeset - JHipster will add changesets here -->

</databaseChangeLog>

@mshima
Copy link
Member

mshima commented Oct 29, 2024

dropColumn will only be generated if incremental changelog is enabled.
Please check if

"incrementalChangelog": true,

Has changed to false in your .yo-rc.json.

Closing since reproduction steps are missing the original jdl and the modified jdl.

@mshima mshima closed this as not planned Won't fix, can't repro, duplicate, stale Oct 29, 2024
@mraible mraible added this to the 8.7.3 milestone Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
@mraible @mshima @flyliu33 and others