Flyway数据库迁移到多个模式 [英] Flyway database migration to multiple schemas
问题描述
我为多租户应用程序设置了迁移脚本。问题是。它只生成我对参数指定的第一个租户/模式的脚本。这是我的sql脚本
删除表如果存在ADMIN_ACCOUNT cascade;
删除表(如果存在)PERSON_NAME cascade;
删除表(如果存在)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,
主键(id)
);
创建表PERSON_NAME(
id int8 not null,
created_date timestamp,
FIRST_NAME varchar(255),
LAST_NAME varchar(255),
MIDDLE_NAME varchar(255),
account_id int8,
主键(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,
主键(id)
);
alter table ADMIN_ACCOUNT
添加约束FK_fil1krx8k0osj713tg44ia0vu
外键(NAME_ID)
引用PERSON_NAME;
alter table PERSON_NAME
添加约束FK_hc1g7pa0rseytw9o1pcuo0mpw
外键(account_id)
引用USER_ACCOUNT;
alter table USER_ACCOUNT
添加约束FK_ib2pk4at20vxm3onaoro6ry2r
外键(NAME_ID)
引用PERSON_NAME;
这是我输入到flyway的命令 mvn compile flyway:migrate -Dflyway .schemas = tenant3,tenant4,tenant5 -Dflyway.baselineOnMigrate = true
它只生成第一个租户的表tenant3。 / p>
这是一个错误吗?
b b p> http://flywaydb.org/documentation/faq.html#multiple-schemas
希望这有助。
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;
Here's the command I have entered to flyway mvn compile flyway:migrate -Dflyway.schemas=tenant3,tenant4,tenant5 -Dflyway.baselineOnMigrate=true
It's only generating the tables for the first tenant which is tenant3.
Is this a bug? or am Missing something?
Please find recommendations from flyway as in
http://flywaydb.org/documentation/faq.html#multiple-schemas
Hope this helps.
这篇关于Flyway数据库迁移到多个模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!