flywayv7.8.1不迁移它创建h2表的第一个脚本

nbnkbykc  于 2021-07-09  发布在  Java
关注(0)|答案(1)|浏览(355)

flywayv7.8.1标识公共模式在h2数据库第一次创建时被更新,并且它不会执行创建示例表的第一个sql脚本。
日志执行为:

[INFO] Running example.credentials.flyway.entities.Test1Flyway
13:39:09:593 (main) DEBUG [i.q.f.r.QuarkusPathLocationScanner] Locations: [classpath:db/migration-test]
13:39:09:596 (main) DEBUG [i.q.f.r.QuarkusPathLocationScanner] Loading db/migration-test/V1.0.0__INITIAL_STRUCTURE_OF_TABLES_WITH_SOME_DATA
13:39:09:603 (main) DEBUG [o.f.c.i.s.c.ClassPathScanner] Scanning for classpath resources at 'classpath:db/callback' ...
13:39:09:604 (main) DEBUG [o.f.c.i.s.c.ClassPathScanner] Determining location urls for classpath:db/callback using ClassLoader QuarkusClassLoader:Quarkus Base Runtime ClassLoader ...
13:39:09:604 (main) DEBUG [o.f.c.i.s.c.ClassPathScanner] Unable to resolve location classpath:db/callback.
13:39:09:609 (main) INFO  [o.f.c.i.l.VersionPrinter] Flyway Community Edition 7.8.1 by Redgate
13:39:09:730 (agroal-11) DEBUG [e.c.f.s.c.CipherManager] Shared key File: shared.key
13:39:09:731 (agroal-11) DEBUG [e.c.f.s.c.CipherManager] Shared key Type File: resource
13:39:09:731 (agroal-11) DEBUG [e.c.f.s.c.CipherManager] LaunchMode (current): TEST
13:39:09:750 (agroal-11) DEBUG [e.c.f.s.MyBbddCredentialsProvider] my-bbdd-credentials-provider/username:tools
13:39:09:750 (agroal-11) DEBUG [e.c.f.s.MyBbddCredentialsProvider] my-bbdd-credentials-provider/password:********
13:39:10:238 (main) INFO  [o.f.c.i.d.b.DatabaseType] Database: jdbc:h2:./target/db/example (H2 1.4)
13:39:10:238 (main) DEBUG [o.f.c.i.d.b.DatabaseType] Driver  : H2 JDBC Driver 1.4.200 (2019-10-14)
13:39:10:328 (main) DEBUG [o.f.c.Flyway] DDL Transactions Supported: false
13:39:10:328 (main) DEBUG [o.f.c.Flyway] Schemas: public
13:39:10:328 (main) DEBUG [o.f.c.Flyway] Default schema: null
13:39:10:333 (main) DEBUG [o.f.c.i.c.SqlScriptCallbackFactory] Scanning for SQL callbacks ...
13:39:10:334 (main) DEBUG [i.q.f.r.FlywayRecorder] Filtering out resource: db/migration-test/V1.0.0__INITIAL_STRUCTURE_OF_TABLES_WITH_SOME_DATA (filename: V1.0.0__INITIAL_STRUCTURE_OF_TABLES_WITH_SOME_DATA)
13:39:10:363 (main) DEBUG [o.f.c.i.c.DbClean] Dropping pre-schema database level objects...
13:39:10:365 (main) INFO  [o.f.c.i.c.DbClean] Successfully dropped pre-schema database level objects (execution time 00:00.001s)
13:39:10:366 (main) WARN  [o.f.c.i.c.DbClean] Unable to clean unknown schema: "public"
13:39:10:366 (main) DEBUG [o.f.c.i.c.DbClean] Dropping post-schema database level objects...
13:39:10:367 (main) INFO  [o.f.c.i.c.DbClean] Successfully dropped post-schema database level objects (execution time 00:00.000s)
13:39:10:367 (agroal-11) DEBUG [e.c.f.s.c.CipherManager] Shared key File: shared.key
13:39:10:368 (agroal-11) DEBUG [e.c.f.s.c.CipherManager] Shared key Type File: resource
13:39:10:368 (agroal-11) DEBUG [e.c.f.s.c.CipherManager] LaunchMode (current): TEST
13:39:10:370 (agroal-11) DEBUG [e.c.f.s.MyBbddCredentialsProvider] my-bbdd-credentials-provider/username:tools
13:39:10:371 (agroal-11) DEBUG [e.c.f.s.MyBbddCredentialsProvider] my-bbdd-credentials-provider/password:********
13:39:10:373 (main) DEBUG [o.f.c.Flyway] Memory usage: 122 of 305M
13:39:10:374 (main) INFO  [o.f.c.i.l.VersionPrinter] Flyway Community Edition 7.8.1 by Redgate
13:39:10:376 (main) DEBUG [o.f.c.Flyway] DDL Transactions Supported: false
13:39:10:377 (main) DEBUG [o.f.c.Flyway] Schemas: public
13:39:10:377 (main) DEBUG [o.f.c.Flyway] Default schema: null
13:39:10:379 (main) DEBUG [o.f.c.i.c.SqlScriptCallbackFactory] Scanning for SQL callbacks ...
13:39:10:379 (main) DEBUG [i.q.f.r.FlywayRecorder] Filtering out resource: db/migration-test/V1.0.0__INITIAL_STRUCTURE_OF_TABLES_WITH_SOME_DATA (filename: V1.0.0__INITIAL_STRUCTURE_OF_TABLES_WITH_SOME_DATA)
13:39:10:390 (main) DEBUG [o.f.c.i.c.DbSchemas] Creating schema: "public"
13:39:10:390 (main) INFO  [o.f.c.i.d.b.Schema] Creating schema "public" ...
13:39:10:400 (main) INFO  [o.f.c.i.s.JdbcTableSchemaHistory] Creating Schema History table "public"."flyway_schema_history" ...
13:39:10:410 (main) DEBUG [o.f.c.i.p.Parser] Parsing  ...
13:39:10:421 (main) DEBUG [o.f.c.i.s.ParserSqlScript] Found statement at line 1: CREATE TABLE IF NOT EXISTS "public"."flyway_schema_history" (
    "installed_rank" INT NOT NULL,
    "version" VARCHAR(50),
    "description" VARCHAR(200) NOT NULL,
    "type" VARCHAR(20) NOT NULL,
    "script" VARCHAR(1000) NOT NULL,
    "checksum" INT,
    "installed_by" VARCHAR(100) NOT NULL,
    "installed_on" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "execution_time" INT NOT NULL,
    "success" BOOLEAN NOT NULL,
    CONSTRAINT "flyway_schema_history_pk" PRIMARY KEY ("installed_rank")
) AS SELECT -1, NULL, '<< Flyway Schema History table created >>', 'TABLE', '', NULL, 'TOOLS', CURRENT_TIMESTAMP, 0, TRUE
13:39:10:422 (main) DEBUG [o.f.c.i.s.ParserSqlScript] Found statement at line 14: CREATE INDEX "public"."flyway_schema_history_s_idx" ON "public"."flyway_schema_history" ("success")
13:39:10:422 (main) DEBUG [o.f.c.i.s.DefaultSqlScriptExecutor] Executing SQL: CREATE TABLE IF NOT EXISTS "public"."flyway_schema_history" (
    "installed_rank" INT NOT NULL,
    "version" VARCHAR(50),
    "description" VARCHAR(200) NOT NULL,
    "type" VARCHAR(20) NOT NULL,
    "script" VARCHAR(1000) NOT NULL,
    "checksum" INT,
    "installed_by" VARCHAR(100) NOT NULL,
    "installed_on" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "execution_time" INT NOT NULL,
    "success" BOOLEAN NOT NULL,
    CONSTRAINT "flyway_schema_history_pk" PRIMARY KEY ("installed_rank")
) AS SELECT -1, NULL, '<< Flyway Schema History table created >>', 'TABLE', '', NULL, 'TOOLS', CURRENT_TIMESTAMP, 0, TRUE
13:39:10:434 (main) DEBUG [o.f.c.i.s.DefaultSqlScriptExecutor] 0 rows affected
13:39:10:434 (main) DEBUG [o.f.c.i.s.DefaultSqlScriptExecutor] Executing SQL: CREATE INDEX "public"."flyway_schema_history_s_idx" ON "public"."flyway_schema_history" ("success")
13:39:10:437 (main) DEBUG [o.f.c.i.s.DefaultSqlScriptExecutor] 0 rows affected
13:39:10:438 (main) DEBUG [o.f.c.i.s.JdbcTableSchemaHistory] Created Schema History table "public"."flyway_schema_history"
13:39:10:456 (main) DEBUG [o.f.c.i.s.JdbcTableSchemaHistory] Schema History table "public"."flyway_schema_history" successfully updated to reflect changes
13:39:10:482 (main) DEBUG [i.q.f.r.FlywayRecorder] Filtering out resource: db/migration-test/V1.0.0__INITIAL_STRUCTURE_OF_TABLES_WITH_SOME_DATA (filename: V1.0.0__INITIAL_STRUCTURE_OF_TABLES_WITH_SOME_DATA)
13:39:10:482 (main) DEBUG [i.q.f.r.FlywayRecorder] Filtering out resource: db/migration-test/V1.0.0__INITIAL_STRUCTURE_OF_TABLES_WITH_SOME_DATA (filename: V1.0.0__INITIAL_STRUCTURE_OF_TABLES_WITH_SOME_DATA)
13:39:10:492 (main) INFO  [o.f.c.i.c.DbMigrate] Current version of schema "public": null
13:39:10:497 (main) INFO  [o.f.c.i.c.DbMigrate] Schema "public" is up to date. No migration necessary.
13:39:10:498 (main) DEBUG [o.f.c.Flyway] Memory usage: 128 of 305M
13:39:11:910 (main) INFO  [e.c.f.e.Test1Flyway] Starting flyway test
13:39:11:916 (main) ERROR [e.c.f.e.ExampleE] SQL Error: : org.h2.jdbc.JdbcSQLSyntaxErrorException: Tabla "T_EXAMPLES" no encontrada
Table "T_EXAMPLES" not found; SQL statement:
INSERT INTO T_EXAMPLES (example_id, description) VALUES (?,?) [42102-200]
        at org.h2.message.DbException.getJdbcSQLException(DbException.java:453)
        at org.h2.message.DbException.getJdbcSQLException(DbException.java:429)

我的quarkus 1.13.2\u final application.yaml配置是:

"%test":
  quarkus:
    log:
      level: ERROR
      console:
        format: "%d{HH:mm:ss:SSS} (%t) %-5p [%c{1.}] %s%e%n"
        color: true
      category:
        "example.credentials.flyway":
          level: DEBUG
        "org.flywaydb.core":
          level: DEBUG
        "io.quarkus.flyway":
          level: DEBUG
        "org.h2":
          level: DEBUG
    datasource:
      db-kind: h2
      jdbc:
        driver: org.h2.Driver

# url: jdbc:h2:tcp://localhost/mem:example;MODE=Oracle

# url: jdbc:h2:./target/db/example;MODE=Oracle,AUTO_SERVER=TRUE

        url: jdbc:h2:./target/db/example;AUTO_SERVER=TRUE
        max-size: 13
    flyway:
      locations: db/migration-test
      clean-at-start: true
      migrate-at-start: true
      schemas: public

我将感谢任何帮助解决这个问题。

lawou6xi

lawou6xi1#

flyway似乎忽略了您的迁移:

[i.q.f.r.FlywayRecorder] Filtering out resource: db/migration-test/V1.0.0__INITIAL_STRUCTURE_OF_TABLES_WITH_SOME_DATA (filename: V1.0.0__INITIAL_STRUCTURE_OF_TABLES_WITH_SOME_DATA)
[i.q.f.r.FlywayRecorder] Filtering out resource: db/migration-test/V1.0.0__INITIAL_STRUCTURE_OF_TABLES_WITH_SOME_DATA (filename: V1.0.0__INITIAL_STRUCTURE_OF_TABLES_WITH_SOME_DATA)

你可能错过了 .sql 脚本上的文件扩展名。

相关问题