conf属性值:
flyway.defaultSchema= discussions
flyway.schemas= discussions
迁移如下:
+-----------+---------+------------------------------+--------+---------------------+---------+
| Category | Version | Description | Type | Installed On | State |
+-----------+---------+------------------------------+--------+---------------------+---------+
| | | << Flyway Schema Creation >> | SCHEMA | 2020-03-23 15:55:38 | Success |
| Versioned | 1 | INITIAL SETUP | SQL | 2020-03-23 15:55:38 | Success |
| Versioned | 2 | R INITIAL SETUP | SQL | | Pending |
| Versioned | 3 | R1 INITIAL SETUP | SQL | | Pending |
| Versioned | 4 | CREATE TABLE TEMPLATE | SQL | | Pending |
初始设置将创建表空间
create tablespace tablespace_dts location 'E:\Tablespace\tablespace_dts';
create tablespace tablespace_mtd location 'E:\Tablespace\tablespace_mtd';
create tablespace tablespace_ind location 'E:\Tablespace\tablespace_ind';
create tablespace tablespace_out location 'E:\Tablespace\tablespace_out';
create tablespace tablespace_temp location 'E:\Tablespace\tablespace_temp';
v2将遵循
begin
for c in select 1 where not exists (select 1 from pg_user where usename = 'app_user' ) loop
raise notice 'in app_user';
execute ' create user app_user with password ''adept''';
end loop;
for c in select 1 where exists (select 1 from pg_tablespace,pg_user where spcname = 'tablespace_dts' and usename = 'app_user') loop
raise notice 'in grant create on tablespace_dts to app_user';
execute 'grant create on tablespace tablespace_dts to app_user with grant option';
end loop;
for c in select 1 where exists (select 1 from pg_tablespace,pg_user where spcname = 'tablespace_mtd' and usename = 'app_user') loop
raise notice 'in grant create on tablespace_mtd to app_user';
execute 'grant create on tablespace tablespace_mtd to app_user with grant option';
end loop;
for c in select 1 where exists (select 1 from pg_tablespace,pg_user where spcname = 'tablespace_ind' and usename = 'app_user') loop
raise notice 'in grant create on tablespace_ind to app_user';
execute 'grant create on tablespace tablespace_ind to app_user with grant option';
end loop;
for c in select 1 where exists (select 1 from pg_tablespace,pg_user where spcname = 'tablespace_out' and usename = 'app_user') loop
raise notice 'in grant create on tablespace_out to app_user';
execute 'grant create on tablespace tablespace_out to app_user with grant option';
end loop;
for c in select 1 where exists (select 1 from pg_tablespace,pg_user where spcname = 'tablespace_temp' and usename = 'app_user') loop
raise notice 'in grant create on tablespace_temp to app_user';
execute 'grant create on tablespace tablespace_temp to app_user with grant option';
end loop;
请注意,此处授予作品
v3将执行以下操作:
grant usage on schema discussions to app_user;
grant select on all tables in schema discussions to app_user;
grant update on all tables in schema discussions to app_user;
grant insert on all tables in schema discussions to app_user;
grant create on schema discussions to app_user with grant option;
v4创建表,例如说webhook_certificate
因此,当我尝试在架构讨论中从app_user查询表webhook_certificate时。 它说,尽管我在v3中授予了权限,但权限被拒绝。
如果手动执行相同的v3,则该v3可以运行并允许访问Discussions.webhook_certificate。 请注意:v3被标记为成功,在迁移过程中没有失败。 那么赠款怎么不起作用。
请帮助。
答案 0 :(得分:0)
我知道了。 感谢您的支持。
作为创建表的V4应该在V3(授权脚本)之前执行。
在现有对象上提供授权。 因此,在每次迁移时,我都需要在最后运行授权脚本。 为此,我可以使用afterMigrate-成功迁移后运行。