flyway如何初始化其数据库
How does flyway init its database
我在使用 spring java 网络应用程序使用 postgresql 数据源配置 flyway 时遇到问题。
即使我这样配置,Flyway 似乎也不会执行迁移操作:
<bean id="flyway" class="com.googlecode.flyway.core.Flyway" init-method="migrate">
<property name="dataSource" ref="dataSource"/>
<property name="table" value="blankapp_schema_version" />
<property name="disableInitCheck" value="true" />
</bean>
当我在 eclipse 中 运行 我的 tomcat (v6) 服务器时,它不会创建 blankapp_schema_version table。我必须将 init-method 更改为 "init" 才能让他创建 table.
blankapp_schema_version table 现已创建,但即使我再次将初始化方法设置为 "migrate",我的第一个脚本(名称为 V001_init.sql ) 并且只是做一个简单的创建 table 似乎没有被执行,因为我没有创建 table 也没有在 blankapp_schema_version table.
此外,我的 tomcat 日志中没有任何错误 我已经设置了从 com.google.flyway 到 trace 的 logback,我仅有的几行是:
17:25:48.822 [main] DEBUG c.g.f.c.dbsupport.DbSupportFactory - Database: PostgreSQL
17:25:48.823 [main] DEBUG com.googlecode.flyway.core.Flyway - Schema: public
仅此而已。
一些上下文:
我的 bean "dataSource" 绑定如下:
<jee:jndi-lookup jndi-name="jdbc/BlankAppDataSource" id="dataSource" />
在我的 META-INF/context.xml 我有:
<Context>
<Resource name="jdbc/BlankAppDataSource"
auth="Container"
type="javax.sql.DataSource"
username="postgres"
password="Weblogic1"
schema="public"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5432/rvandecaveye"
/>
</Context>
如果您的迁移版本小于或等于 blankapp_schema_version table 中的架构版本,则不会 运行 迁移。
您可以通过添加 属性 initDescription
来设置初始架构版本的值。
所以运行你的V001脚本,initDescription
参数应该是0
。
我在使用 spring java 网络应用程序使用 postgresql 数据源配置 flyway 时遇到问题。
即使我这样配置,Flyway 似乎也不会执行迁移操作:
<bean id="flyway" class="com.googlecode.flyway.core.Flyway" init-method="migrate">
<property name="dataSource" ref="dataSource"/>
<property name="table" value="blankapp_schema_version" />
<property name="disableInitCheck" value="true" />
</bean>
当我在 eclipse 中 运行 我的 tomcat (v6) 服务器时,它不会创建 blankapp_schema_version table。我必须将 init-method 更改为 "init" 才能让他创建 table.
blankapp_schema_version table 现已创建,但即使我再次将初始化方法设置为 "migrate",我的第一个脚本(名称为 V001_init.sql ) 并且只是做一个简单的创建 table 似乎没有被执行,因为我没有创建 table 也没有在 blankapp_schema_version table.
此外,我的 tomcat 日志中没有任何错误 我已经设置了从 com.google.flyway 到 trace 的 logback,我仅有的几行是:
17:25:48.822 [main] DEBUG c.g.f.c.dbsupport.DbSupportFactory - Database: PostgreSQL
17:25:48.823 [main] DEBUG com.googlecode.flyway.core.Flyway - Schema: public
仅此而已。
一些上下文:
我的 bean "dataSource" 绑定如下:
<jee:jndi-lookup jndi-name="jdbc/BlankAppDataSource" id="dataSource" />
在我的 META-INF/context.xml 我有:
<Context>
<Resource name="jdbc/BlankAppDataSource"
auth="Container"
type="javax.sql.DataSource"
username="postgres"
password="Weblogic1"
schema="public"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5432/rvandecaveye"
/>
</Context>
如果您的迁移版本小于或等于 blankapp_schema_version table 中的架构版本,则不会 运行 迁移。
您可以通过添加 属性 initDescription
来设置初始架构版本的值。
所以运行你的V001脚本,initDescription
参数应该是0
。