SQL 启动时不执行脚本

SQL script is not executed during startup

我想在启动 Spring 启动应用程序时总是 运行 SQL 脚本。我添加了这个 Liquibase 配置:

application.yml

spring:
  datasource:
    platform: org.hibernate.dialect.PostgreSQL95Dialect
    url: jdbc:postgresql://10.10.10.10:5432/test
    driverClassName: org.postgresql.Driver
    username: root
    password: test
  liquibase:
    changeLog: 'classpath:db/changelog/db.changelog-master.yaml'
    dropFirst: false
  jpa:
    hibernate:
      ddl-auto: update
    show-sql: true
    database: postgresql

db.changelog-master.yaml

databaseChangeLog:
  - include:
      file: db/changelog/changes/ch_0001/changelog.yaml

changelog.yaml

databaseChangeLog:
  - include:
      file: db/changelog/changes/ch_0001/data/data.yaml

data.yaml

databaseChangeLog:
  - changeSet:
      id: 0001
      author: test
      dbms: postgres
      runAlways: true # WARNING - remove this before prod - it will run every time with clean data
      changes:
        - sqlFile:
            - relativeToChangelogFile: true
            - path: data.sql

data.sql

INSERT into tasks SELECT generate_series(1,355) AS id,
    left (md5(random()::text), 10) AS business_name,
    (select NOW() + (random() * (NOW()+'90 days' - NOW())) + '30 days') AS created_at,
    left (md5(random()::text), 10) AS meta_title,
    left (md5(random()::text), 10) AS status,
    left (md5(random()::text), 10) AS title,
    left (md5(random()::text), 10) AS task_type,
    (select NOW() + (random() * (NOW()+'90 days' - NOW())) + '30 days') AS updated_at;

数据库table 应填充测试数据,但事实并非如此。我没有看到日志 data.sql 文件执行。

您知道可能是什么问题吗?

好像你没有添加完整的配置。

尝试添加这些。

spring:
  liquibase:
    change-log: classpath:db/changelog/db.changelog-master.yaml
    url: {same as spring.datasource.url}
    user: {same as spring.datasource.username}
    password: {same as spring.datasource.password}
    enabled: true

更新

对于 Postgres DB dbmd 值为 postgresql。不是 postgres。 参考 - Here

已更新data.yml

databaseChangeLog:
  - changeSet:
      id: 0001
      author: test
      dbms: postgresql
      runAlways: true # WARNING - remove this before prod - it will run every time with clean data
      changes:
        - sqlFile:
            - relativeToChangelogFile: true
            - path: data.sql