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

opened this issue · comments

Can the subzero-migrations command ignore space or tab?

What do you mean by that? Spaces where?

After I built the migration script, I need to manually move around the code in order for those scripts to run in test env, then the next time I build the migration script, subzero does not recognize those codes. I checked the only differences are space and tab.

Still not sure i follow :)
Can you paste here some sample sql in both "versions", first the exact thing the cli generated (and breaks) then the "adjusted" version (that fixes the problem)

Ex : api, data schema
Here is a view in api schema.
In the api schema

create or replace view p_v as
select a   ,b     ,c     ,d     ,e
	  from (
		select 
			a,  b,
			data.get_p(tb.d), -- a newfunction in data schema 
			e 
			from data.p_table tb
	  );
	 

In the data schema
create table p_table a, b, c, d, e .......

After subzero-migration add "version 1 "

-----------here is subzero-migration add script
SET search_path = api 
create or replace view p_v as .... ...

**SET search_path = data
create table p_table 
create function get_p**
---end of subzero-migration add script

The problem is I need to move the script as

-----------here is rewrite subzero-migration add script
**SET search_path = data
create function get_p
create table p_table** 

SET search_path = api 
create or replace view p_v as

SET search_path = data
.......
 
---end of rewrite subzero-migration add script

After a few days, I create subzero-migration add "version 2". then those parts of the code will be auto add to the version 2 script, because the spaces and tabs

**SET search_path = data
create function get_p
create table p_table** 

i am not sure about the view but it's possible that the function definition is diffed/compared as a simple string so if you move around the function definition and your editor changes tabs to spaces (or the other way) you will get the mentioned behavior.

the create table comes back probably because it depends on the function.

If you are using migra, this is mentioned here djrobstep/migra#188

Not sure there is a good solution besides "don't change (you or the editor) the lines referring to the function body in the generated migration file". apgdiff might probably have the same behaviour