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

Liquibase change logs would be regenerated for microservices, though there is no modify on jdl. #27789

Open
1 task done
flyliu33 opened this issue Nov 4, 2024 · 5 comments

Comments

@flyliu33
Copy link

flyliu33 commented Nov 4, 2024

Overview of the issue

While I have somthing modified for my jdl file, I would execute jhipster jdl microservice-ecommerce-store-4-apps.jdl. However, it would also regenerate liquibase changelog for some entities which didn't change. And these repeated changelog files would also be referenced to master.xml.

image

Motivation for or Use Case

maintain regular business feature.

Reproduce the error
  1. execute jhipster jdl microservice-ecommerce-store-4-apps.jdl several times without modifying the jdl file.
Related issues
Suggest a Fix
JHipster Version(s)

8.7.3

JHipster configuration

microservice-ecommerce-store-4-apps.txt

.yo-rc.json file
{
  "generator-jhipster": {
    "applicationIndex": 0,
    "applicationType": "gateway",
    "applications": {
      "invoice": {
        "applicationIndex": 2,
        "serverPort": "8082"
      },
      "notification": {
        "applicationIndex": 3,
        "serverPort": "8083"
      },
      "product": {
        "applicationIndex": 1,
        "serverPort": "8081"
      }
    },
    "authenticationType": "jwt",
    "baseName": "store",
    "buildTool": "maven",
    "cacheProvider": "no",
    "clientFramework": "vue",
    "devServerPort": 9060,
    "entities": [
      "Customer",
      "Product",
      "ProductCategory",
      "ProductOrder",
      "OrderItem",
      "Invoice",
      "Shipment",
      "Notification"
    ],
    "jhipsterVersion": "8.7.3",
    "languages": [
      "en"
    ],
    "lastLiquibaseTimestamp": 1730345890000,
    "nativeLanguage": "en",
    "packageName": "com.jhipster.demo.store",
    "prodDatabaseType": "mysql",
    "reactive": true,
    "serverPort": 8080,
    "serviceDiscoveryType": "consul",
    "testFrameworks": [
      "cypress"
    ]
  }
}
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
@ChangelogDate("20241031033110")
entity Customer {
  firstName String required
  lastName String required
  gender Gender required
  email String required pattern(/^[^@\s]+@[^@\s]+\.[^@\s]+$/)
  phone String required
  addressLine1 String required
  addressLine2 String
  city String required
  country String required
}
/**
 * Product sold by the Online store
 */
@ChangelogDate("20241031033210")
entity Product {
  name String required
  description String
  price BigDecimal required min(0)
  productSize Size required
  image ImageBlob
}
@ChangelogDate("20241031033310")
entity ProductCategory {
  name String required
  description String
}
@ChangelogDate("20241031033410")
entity ProductOrder {
  placedDate Instant required
  status OrderStatus required
  code String required
  invoiceId Long
  customer String required
}
@ChangelogDate("20241031033510")
entity OrderItem {
  quantity Integer required min(0)
  totalPrice BigDecimal required min(0)
  status OrderItemStatus required
}
@ChangelogDate("20241031033610")
entity Invoice {
  code String required
  date Instant required
  details String
  status InvoiceStatus required
  paymentMethod PaymentMethod required
  paymentDate Instant required
  paymentAmount BigDecimal required
}
@ChangelogDate("20241031033710")
entity Shipment {
  trackingCode String
  date Instant required
  details String
}
@ChangelogDate("20241031033810")
entity Notification {
  date Instant required
  details String
  sentDate Instant required
  format NotificationType required
  userId Long required
  productId Long required
}

enum Gender {
  MALE,
  FEMALE,
  OTHER
}
enum Size {
  S,
  M,
  L,
  XL,
  XXL
}
enum OrderStatus {
  COMPLETED,
  PENDING,
  CANCELLED
}
enum OrderItemStatus {
  AVAILABLE,
  OUT_OF_STOCK,
  BACK_ORDER
}
enum InvoiceStatus {
  PAID,
  ISSUED,
  CANCELLED
}
enum PaymentMethod {
  CREDIT_CARD,
  CASH_ON_DELIVERY,
  PAYPAL
}
enum NotificationType {
  EMAIL,
  SMS,
  PARCEL
}

relationship OneToOne {
  Customer{user(login) required} to User with builtInEntity
}
relationship OneToMany {
  ProductCategory{product} to Product{productCategory(name)}
  ProductOrder{orderItem} to OrderItem{order(code) required}
  Invoice{shipment} to Shipment{invoice(code) required}
}
relationship ManyToOne {
  OrderItem{product(name) required} to Product
}

paginate Customer, Product, ProductOrder, OrderItem, Invoice, Shipment with pagination
service Customer, Product, ProductCategory, ProductOrder, OrderItem, Invoice, Shipment with serviceClass
search Customer, Product, ProductCategory, ProductOrder, OrderItem, Invoice, Shipment, Notification with no
microservice Product, ProductCategory, ProductOrder, OrderItem with product
microservice Invoice, Shipment with invoice
microservice Notification with notification
clientRootFolder Product, ProductCategory, ProductOrder, OrderItem with product
clientRootFolder Invoice, Shipment with invoice
clientRootFolder Notification with notification

Browsers and Operating System

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

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

mshima commented Nov 4, 2024

You should use --incremental-changelog.

@flyliu33
Copy link
Author

flyliu33 commented Nov 5, 2024

I tried your recommendation, it was still the same problem, and creating the fake data, csv files, additionally.
my command was jhipster jdl .\microservice-ecommerce-store-4-apps.jdl --incremental-changelog, it needs to execute twice. First, it will only generate .yo-rc and entity json files.

image

Second, it will generate the rest of files, but not the target increments files.
image

Additionally, after executing command jhipster jdl .\microservice-ecommerce-store-4-apps.jdl --incremental-changelog for several times, there was another issue arose. And command jhipster jdl .\microservice-ecommerce-store-4-apps.jdl --incremental-changelog didn't work.

 conflict store\src\main\webapp\app\entities\customer\customer-details.vue
ERROR! An error occured while running jhipster:workspaces#generateApplications
ERROR! ERROR! Prompt was aborted
AbortPromptError: Prompt was aborted
    at abort (file:///C:/Users/flyli/AppData/Roaming/nvm/v20.17.0/node_modules/generator-jhipster/node_modules/@inquirer/core/dist/esm/lib/create-prompt.js:27:40)
    at prompt (file:///C:/Users/flyli/AppData/Roaming/nvm/v20.17.0/node_modules/generator-jhipster/node_modules/@inquirer/core/dist/esm/lib/create-prompt.js:29:17)
    at PromptsRunner.fetchAnswer (file:///C:/Users/flyli/AppData/Roaming/nvm/v20.17.0/node_modules/generator-jhipster/node_modules/inquirer/dist/esm/ui/prompt.js:228:16) {
  cause: DOMException [AbortError]: This operation was aborted
      at new DOMException (node:internal/per_context/domexception:53:5)
      at AbortController.abort (node:internal/abort_controller:391:18)
      at TerminalAdapter.close (file:///C:/Users/flyli/AppData/Roaming/nvm/v20.17.0/node_modules/generator-jhipster/node_modules/@yeoman/adapter/dist/adapter.js:51:30)
      at QueuedAdapter.close (file:///C:/Users/flyli/AppData/Roaming/nvm/v20.17.0/node_modules/generator-jhipster/node_modules/@yeoman/adapter/dist/queued-adapter.js:55:28)
      at FullEnvironment.<anonymous> (file:///C:/Users/flyli/AppData/Roaming/nvm/v20.17.0/node_modules/generator-jhipster/node_modules/yeoman-environment/dist/environment-base.js:589:30)
}

@flyliu33
Copy link
Author

flyliu33 commented Nov 5, 2024

BTW, command jhipster jdl .\microservice-ecommerce-store-4-apps.jdl --incremental-changelog --auto-crlf cannot work properly for me, So I tried command jhipster jdl .\microservice-ecommerce-store-4-apps.jdl --skip-db-changelog --auto-crlf and ./mvnw compile liquibase:diff, how ever it would make following error without any output. But this two commands can work properly for monolithic project.

Starting Liquibase at 14:23:26 (version 4.27.0 #1525 built at 2024-03-25 17:08+0000)
[INFO] Settings
----------------------------
[INFO]     driver: com.mysql.cj.jdbc.Driver
[INFO]     url: jdbc:mysql://localhost:3306/store
[INFO]     username: *****
[INFO]     password: *****
[INFO]     use empty password: false
[INFO]     properties file: null
[INFO]     properties file will override? false
[INFO]     clear checksums? false
[INFO]     changeLogDirectory: null
[INFO]     changeLogFile: config/liquibase/master.xml
[INFO]     context(s): !test
[INFO]     referenceDriver: null
[INFO]     referenceUrl: null
[INFO]     referenceUsername: *****
[INFO]     referencePassword: *****
[INFO]     referenceDefaultSchema: null
[INFO]     diffChangeLogFile: D:\workspace\test\jhipster\ms-ecommerce-store\store/src/main/resources/config/liquibase/changelog/20241105062305_changelog.xml
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  21.308 s
[INFO] Finished at: 2024-11-05T14:23:26+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:4.27.0:diff (default-cli) on project store: A reference database must be provided to perform a diff. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

@mshima
Copy link
Member

mshima commented Nov 5, 2024

I tried your recommendation, it was still the same problem, and creating the fake data, csv files, additionally.
my command was jhipster jdl .\microservice-ecommerce-store-4-apps.jdl --incremental-changelog, it needs to execute twice. First, it will only generate .yo-rc and entity json files.

Incremental changelog only works if there’s an existing project.
First run it will create the full project.
Then you can modify your jdl.
.jhipster must exist with old entity definitions so a diff can be calculated.

@flyliu33
Copy link
Author

flyliu33 commented Nov 6, 2024

I tried your recommendation, it was still the same problem, and creating the fake data, csv files, additionally.
my command was jhipster jdl .\microservice-ecommerce-store-4-apps.jdl --incremental-changelog, it needs to execute twice. First, it will only generate .yo-rc and entity json files.

Incremental changelog only works if there’s an existing project. First run it will create the full project. Then you can modify your jdl. .jhipster must exist with old entity definitions so a diff can be calculated.

Yes, I did follow your recommendations.
This is my original jdl file.
original-microservice-ecommerce-store-4-apps.txt

This is my modified jdl file.
modified-microservice-ecommerce-store-4-apps.txt

Reproduction steps:

  1. executive jhipster jdl .\original-microservice-ecommerce-store-4-apps.jdl --auto-crlf
  2. waiting for the command executed successfully, then modify the jdl file just adding a simple entry to Product entity.
  3. executive jhipster jdl .\modified-microservice-ecommerce-store-4-apps.jdl --incremental-changelog --auto-crlf
  4. couldn't generate the changlog properly for Product.json and the rest of the codes. However it would modify all of the .yo-rc.json and Entity.json, adding "incrementalChangelog": true, in .yo-rc.json and adding "incrementalChangelog": false, in Entity.json

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

2 participants