subzerocloud / subzero-cli

Tooling to aid development of subZero/PostgREST based backend APIs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"subzero-migrations add" command is not working for a table with partition

opened this issue · comments

I have created a table with
For example :
create table aaa (
ac integer NOT NULL
,bc TIMESTAMP NOT NULL
,primary key (ac)

)partition by list (ac);
create table aaa1 partition of aaa for values in (1);
create table aaa2 partition of aaa for values in (2);
Then I run subzero migrations add --dry-run --with-privileges --note ****
I got an error :
Exception in thread "main" cz.startnet.utils.pgdiff.parsers.ParserException: Cannot parse string: CREATE TABLE aa (


)
PARTITION BY LIST (ab_partitions_num);
Unsupported command at position 668 'PARTITION BY LIST (a'
at cz.startnet.utils.pgdiff.parsers.Parser.throwUnsupportedCommand(Parser.java:404)
at cz.startnet.utils.pgdiff.parsers.CreateTableParser.parse(CreateTableParser.java:103)
at cz.startnet.utils.pgdiff.loader.PgDumpLoader.loadDatabaseSchema(PgDumpLoader.java:244)
at cz.startnet.utils.pgdiff.loader.PgDumpLoader.loadDatabaseSchema(PgDumpLoader.java:322)
at cz.startnet.utils.pgdiff.PgDiff.createDiff(PgDiff.java:35)
at cz.startnet.utils.pgdiff.Main.main(Main.java:39)

And files created in the deploy, revert and verify folder are all empty.

The error comes from apgdiff, can you try the same command but this time add the parameter --diff-tool migra ?

Hi
Thanks for it.
subzero migrations add --diff-tool migra --with-privileges --note "***", It is working the aaa table with partition generated. But it is not fully copied another view thing to the file in the deploy folder.
For example :
create or replace view bbb_v as select * from bbb ; -- copied
Alert view bbb_v owner to api ; -- not copied.
comment on view bbb_v is *** ; -- not copied.

Migra does not support “priveleges export” but that is not a big downside. Take a look at this comment to see how to better handle privileges (reset them after each migration) #55 (comment)

Also yhere is a way to autocomplete the cli parameters with env vars like this https://github.com/subzerocloud/subzero-starter-kit/blob/master/.env#L7

Thanks