Flyway 迁移不适用于 gradle

djW*_*ann 5 sql gradle flyway

我正在尝试使用 gradle 脚本迁移一些 SQL 表:

buildscript {
  repositories {
    maven {
      url "https://plugins.gradle.org/m2/"
    }
  }
  dependencies {
    classpath 'gradle.plugin.com.boxfuse.client:flyway-release:4.0.3'
    classpath group: 'org.postgresql', name: 'postgresql', version: '9.4.1208.jre7'
  }
}

apply plugin: 'org.flywaydb.flyway'

flyway {
  user = 'postgres'
  url = 'jdbc:postgresql://localhost:5432/test'
  driver = 'org.postgresql.Driver'
  locations = ['filesystem:scripts']
}
Run Code Online (Sandbox Code Playgroud)

脚本目录中我只有一个 SQL 脚本:

CREATE TABLE place (
  id VARCHAR(50) NOT NULL,
  country VARCHAR(255),
  country_code VARCHAR(255),
  name VARCHAR(255),
  PRIMARY KEY(id)
);
Run Code Online (Sandbox Code Playgroud)

当我运行时,gradle flywayMigrate -i我得到输出:

Database: jdbc:postgresql://localhost:5432/test (PostgreSQL 9.5)
Successfully validated 0 migrations (execution time 00:00.009s)
Current version of schema "public": << Empty Schema >>
Schema "public" is up to date. No migration necessary.
Run Code Online (Sandbox Code Playgroud)

测试数据库中,创建了 schema_version表,但没有创建表place 。

Flyway的目录结构是:

flyway-dir
  -- build.gradle
  -- scripts/001-add_place_table.sql
Run Code Online (Sandbox Code Playgroud)

我是否缺少飞行路线的一些附加设置?非常不幸的是我没有收到任何错误消息。

Opa*_*pal 5

您似乎认为迁移脚本的命名不正确。请适当地命名脚本 -请参阅命名部分