Flyway database migration to multiple schemas(Flyway 数据库迁移到多个模式)
问题描述
我已经为我的多租户应用程序设置了一个迁移脚本.问题是.它只为我在参数上指定的第一个租户/模式生成脚本.这是我的 sql 脚本
I've set up a migration script for my multi-tenant application. the problem was. it's only generating the scripts for the first tenant/schema I've specified on the parameter. Here's my sql script
drop table if exists ADMIN_ACCOUNT cascade;
drop table if exists PERSON_NAME cascade;
drop table if exists USER_ACCOUNT cascade;
create table ADMIN_ACCOUNT (
id int8 not null,
created_date timestamp,
PASSWORD varchar(255),
USERNAME varchar(255),
membershipType varchar(255),
NAME_ID int8,
primary key (id)
);
create table PERSON_NAME (
id int8 not null,
created_date timestamp,
FIRST_NAME varchar(255),
LAST_NAME varchar(255),
MIDDLE_NAME varchar(255),
account_id int8,
primary key (id)
);
create table USER_ACCOUNT (
id int8 not null,
created_date timestamp,
PASSWORD varchar(255),
USERNAME varchar(255),
ROLE varchar(255),
TENANT_CODE varchar(255),
NAME_ID int8,
primary key (id)
);
alter table ADMIN_ACCOUNT
add constraint FK_fil1krx8k0osj713tg44ia0vu
foreign key (NAME_ID)
references PERSON_NAME;
alter table PERSON_NAME
add constraint FK_hc1g7pa0rseytw9o1pcuo0mpw
foreign key (account_id)
references USER_ACCOUNT;
alter table USER_ACCOUNT
add constraint FK_ib2pk4at20vxm3onaoro6ry2r
foreign key (NAME_ID)
references PERSON_NAME;
这是我输入flyway的命令mvn compile flyway:migrate -Dflyway.schemas=tenant3,tenant4,tenant5 -Dflyway.baselineOnMigrate=true
Here's the command I have entered to flyway mvn compile flyway:migrate -Dflyway.schemas=tenant3,tenant4,tenant5 -Dflyway.baselineOnMigrate=true
它只为第一个租户(tenant3)生成表.
It's only generating the tables for the first tenant which is tenant3.
这是一个错误吗?还是错过了什么?
Is this a bug? or am Missing something?
推荐答案
要创建多个相同的模式,您必须为每个模式调用一次 Flyway,并将 flyway.schemas 属性设置为正确的值.然后,Flyway 会将正确的架构设置为默认架构,让您以不变的方式运行迁移脚本(只要您不为对象名称添加前缀).
To create multiple identical schemas you have to invoke Flyway once for each schema, with the flyway.schemas property set the to correct value. Flyway will then set the correct schema as the default one, letting you run your migration scripts unchanged (as long as you don't prefix the object names).
这篇关于Flyway 数据库迁移到多个模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Flyway 数据库迁移到多个模式
基础教程推荐
- 如何对 HashSet 进行排序? 2022-01-01
- 首次使用 Hadoop,MapReduce Job 不运行 Reduce Phase 2022-01-01
- 如何使用 Stream 在集合中拆分奇数和偶数以及两者的总和 2022-01-01
- Java 中保存最后 N 个元素的大小受限队列 2022-01-01
- 如何使用 Eclipse 检查调试符号状态? 2022-01-01
- 如何强制对超级方法进行多态调用? 2022-01-01
- 在螺旋中写一个字符串 2022-01-01
- 如何在不安装整个 WTP 包的情况下将 Tomcat 8 添加到 Eclipse Kepler 2022-01-01
- 由于对所需库 rt.jar 的限制,对类的访问限制? 2022-01-01
- Spring Boot Freemarker从2.2.0升级失败 2022-01-01