-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '17130_field_type_partitioned_table' into 'master'
17130 field type partitioned table See merge request codekeeper/codekeeper!319
- Loading branch information
Showing
9 changed files
with
271 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
....tests/src/main/resources/cz/startnet/utils/pgdiff/drop_col_from_partitioned_tbl_diff.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
SET search_path = pg_catalog; | ||
|
||
ALTER TABLE public.cities | ||
DROP COLUMN bstat; | ||
|
||
-- DEPCY: This COLUMN depends on the COLUMN: public.cities.qwe | ||
|
||
ALTER TABLE ONLY public.cities_ab_10000_to_100000 | ||
ALTER COLUMN qwe DROP DEFAULT; | ||
|
||
-- DEPCY: This COLUMN depends on the COLUMN: public.cities.qwe | ||
|
||
ALTER TABLE ONLY public.cities_ab | ||
ALTER COLUMN qwe DROP DEFAULT; | ||
|
||
-- DEPCY: This COLUMN depends on the COLUMN: public.cities.qwe | ||
|
||
ALTER TABLE ONLY public.cities_partdef | ||
ALTER COLUMN qwe DROP DEFAULT; | ||
|
||
ALTER TABLE public.cities | ||
DROP COLUMN qwe; |
40 changes: 40 additions & 0 deletions
40
...f.tests/src/main/resources/cz/startnet/utils/pgdiff/drop_col_from_partitioned_tbl_new.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
CREATE SEQUENCE public.cities_city_id_seq | ||
START WITH 1 | ||
INCREMENT BY 1 | ||
NO MAXVALUE | ||
NO MINVALUE | ||
CACHE 1; | ||
|
||
-------------------------------------------------------------------------------- | ||
|
||
CREATE TABLE public.cities ( | ||
city_id bigint DEFAULT nextval('public.cities_city_id_seq'::regclass) NOT NULL, | ||
name text NOT NULL, | ||
population bigint | ||
) | ||
PARTITION BY LIST ("left"(lower(name), 1)); | ||
|
||
-------------------------------------------------------------------------------- | ||
|
||
CREATE TABLE public.cities_partdef PARTITION OF public.cities | ||
DEFAULT; | ||
|
||
ALTER TABLE ONLY public.cities_partdef ALTER COLUMN city_id SET DEFAULT nextval('public.cities_city_id_seq'::regclass); | ||
|
||
-------------------------------------------------------------------------------- | ||
|
||
CREATE TABLE public.cities_ab PARTITION OF public.cities | ||
FOR VALUES IN ('a', 'b') | ||
PARTITION BY RANGE (population); | ||
|
||
ALTER TABLE ONLY public.cities_ab ALTER COLUMN city_id SET DEFAULT nextval('public.cities_city_id_seq'::regclass); | ||
|
||
ALTER TABLE public.cities_ab | ||
ADD CONSTRAINT city_id_nonzero CHECK ((city_id <> 0)); | ||
|
||
-------------------------------------------------------------------------------- | ||
|
||
CREATE TABLE public.cities_ab_10000_to_100000 PARTITION OF public.cities_ab | ||
FOR VALUES FROM ('10000') TO ('100000'); | ||
|
||
ALTER TABLE ONLY public.cities_ab_10000_to_100000 ALTER COLUMN city_id SET DEFAULT nextval('public.cities_city_id_seq'::regclass); |
48 changes: 48 additions & 0 deletions
48
...ts/src/main/resources/cz/startnet/utils/pgdiff/drop_col_from_partitioned_tbl_original.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
CREATE SEQUENCE public.cities_city_id_seq | ||
START WITH 1 | ||
INCREMENT BY 1 | ||
NO MAXVALUE | ||
NO MINVALUE | ||
CACHE 1; | ||
|
||
-------------------------------------------------------------------------------- | ||
|
||
CREATE TABLE public.cities ( | ||
city_id bigint DEFAULT nextval('public.cities_city_id_seq'::regclass) NOT NULL, | ||
name text NOT NULL, | ||
population bigint, | ||
bstat integer, | ||
qwe text DEFAULT USER | ||
) | ||
PARTITION BY LIST ("left"(lower(name), 1)); | ||
|
||
-------------------------------------------------------------------------------- | ||
|
||
CREATE TABLE public.cities_partdef PARTITION OF public.cities | ||
DEFAULT; | ||
|
||
ALTER TABLE ONLY public.cities_partdef ALTER COLUMN city_id SET DEFAULT nextval('public.cities_city_id_seq'::regclass); | ||
|
||
ALTER TABLE ONLY public.cities_partdef ALTER COLUMN qwe SET DEFAULT USER; | ||
|
||
-------------------------------------------------------------------------------- | ||
|
||
CREATE TABLE public.cities_ab PARTITION OF public.cities | ||
FOR VALUES IN ('a', 'b') | ||
PARTITION BY RANGE (population); | ||
|
||
ALTER TABLE ONLY public.cities_ab ALTER COLUMN city_id SET DEFAULT nextval('public.cities_city_id_seq'::regclass); | ||
|
||
ALTER TABLE ONLY public.cities_ab ALTER COLUMN qwe SET DEFAULT USER; | ||
|
||
ALTER TABLE public.cities_ab | ||
ADD CONSTRAINT city_id_nonzero CHECK ((city_id <> 0)); | ||
|
||
-------------------------------------------------------------------------------- | ||
|
||
CREATE TABLE public.cities_ab_10000_to_100000 PARTITION OF public.cities_ab | ||
FOR VALUES FROM ('10000') TO ('100000'); | ||
|
||
ALTER TABLE ONLY public.cities_ab_10000_to_100000 ALTER COLUMN city_id SET DEFAULT nextval('public.cities_city_id_seq'::regclass); | ||
|
||
ALTER TABLE ONLY public.cities_ab_10000_to_100000 ALTER COLUMN qwe SET DEFAULT USER; |
42 changes: 42 additions & 0 deletions
42
...s/src/main/resources/cz/startnet/utils/pgdiff/modify_col_type_in_partitioned_tbl_diff.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
SET search_path = pg_catalog; | ||
|
||
-- DEPCY: This COLUMN depends on the COLUMN: public.measurement_year_month.unitsales | ||
|
||
ALTER TABLE ONLY public.measurement_ym_y2017m01 | ||
ALTER COLUMN unitsales DROP DEFAULT; | ||
|
||
-- DEPCY: This COLUMN depends on the COLUMN: public.measurement_year_month.unitsales | ||
|
||
ALTER TABLE ONLY public.measurement_ym_y2016m12 | ||
ALTER COLUMN unitsales DROP DEFAULT; | ||
|
||
-- DEPCY: This COLUMN depends on the COLUMN: public.measurement_year_month.unitsales | ||
|
||
ALTER TABLE ONLY public.measurement_ym_y2016m11 | ||
ALTER COLUMN unitsales DROP DEFAULT; | ||
|
||
-- DEPCY: This COLUMN depends on the COLUMN: public.measurement_year_month.unitsales | ||
|
||
ALTER TABLE ONLY public.measurement_ym_older | ||
ALTER COLUMN unitsales DROP DEFAULT; | ||
|
||
ALTER TABLE ONLY public.measurement_year_month | ||
ALTER COLUMN unitsales DROP DEFAULT; | ||
|
||
ALTER TABLE public.measurement_year_month | ||
ALTER COLUMN unitsales TYPE text USING unitsales::text; /* TYPE change - table: public.measurement_year_month original: integer new: text */ | ||
|
||
ALTER TABLE ONLY public.measurement_year_month | ||
ALTER COLUMN unitsales SET DEFAULT USER; | ||
|
||
ALTER TABLE ONLY public.measurement_ym_y2017m01 | ||
ALTER COLUMN unitsales SET DEFAULT USER; | ||
|
||
ALTER TABLE ONLY public.measurement_ym_y2016m12 | ||
ALTER COLUMN unitsales SET DEFAULT USER; | ||
|
||
ALTER TABLE ONLY public.measurement_ym_y2016m11 | ||
ALTER COLUMN unitsales SET DEFAULT USER; | ||
|
||
ALTER TABLE ONLY public.measurement_ym_older | ||
ALTER COLUMN unitsales SET DEFAULT USER; |
30 changes: 30 additions & 0 deletions
30
...ts/src/main/resources/cz/startnet/utils/pgdiff/modify_col_type_in_partitioned_tbl_new.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
CREATE TABLE public.measurement_year_month ( | ||
logdate date NOT NULL, | ||
peaktemp integer, | ||
unitsales text DEFAULT USER | ||
) | ||
PARTITION BY RANGE (date_part('year'::text, logdate), date_part('month'::text, logdate)); | ||
|
||
|
||
CREATE TABLE public.measurement_ym_older PARTITION OF public.measurement_year_month | ||
FOR VALUES FROM (MINVALUE, MINVALUE) TO ('2016', '11'); | ||
|
||
ALTER TABLE ONLY public.measurement_ym_older ALTER COLUMN unitsales SET DEFAULT USER; | ||
|
||
|
||
CREATE TABLE public.measurement_ym_y2016m11 PARTITION OF public.measurement_year_month | ||
FOR VALUES FROM ('2016', '11') TO ('2016', '12'); | ||
|
||
ALTER TABLE ONLY public.measurement_ym_y2016m11 ALTER COLUMN unitsales SET DEFAULT USER; | ||
|
||
|
||
CREATE TABLE public.measurement_ym_y2016m12 PARTITION OF public.measurement_year_month | ||
FOR VALUES FROM ('2016', '12') TO ('2017', '1'); | ||
|
||
ALTER TABLE ONLY public.measurement_ym_y2016m12 ALTER COLUMN unitsales SET DEFAULT USER; | ||
|
||
|
||
CREATE TABLE public.measurement_ym_y2017m01 PARTITION OF public.measurement_year_month | ||
FOR VALUES FROM ('2017', '1') TO ('2017', '2'); | ||
|
||
ALTER TABLE ONLY public.measurement_ym_y2017m01 ALTER COLUMN unitsales SET DEFAULT USER; |
30 changes: 30 additions & 0 deletions
30
...c/main/resources/cz/startnet/utils/pgdiff/modify_col_type_in_partitioned_tbl_original.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
CREATE TABLE public.measurement_year_month ( | ||
logdate date NOT NULL, | ||
peaktemp integer, | ||
unitsales integer DEFAULT 5234 | ||
) | ||
PARTITION BY RANGE (date_part('year'::text, logdate), date_part('month'::text, logdate)); | ||
|
||
|
||
CREATE TABLE public.measurement_ym_older PARTITION OF public.measurement_year_month | ||
FOR VALUES FROM (MINVALUE, MINVALUE) TO ('2016', '11'); | ||
|
||
ALTER TABLE ONLY public.measurement_ym_older ALTER COLUMN unitsales SET DEFAULT 5234; | ||
|
||
|
||
CREATE TABLE public.measurement_ym_y2016m11 PARTITION OF public.measurement_year_month | ||
FOR VALUES FROM ('2016', '11') TO ('2016', '12'); | ||
|
||
ALTER TABLE ONLY public.measurement_ym_y2016m11 ALTER COLUMN unitsales SET DEFAULT 5234; | ||
|
||
|
||
CREATE TABLE public.measurement_ym_y2016m12 PARTITION OF public.measurement_year_month | ||
FOR VALUES FROM ('2016', '12') TO ('2017', '1'); | ||
|
||
ALTER TABLE ONLY public.measurement_ym_y2016m12 ALTER COLUMN unitsales SET DEFAULT 5234; | ||
|
||
|
||
CREATE TABLE public.measurement_ym_y2017m01 PARTITION OF public.measurement_year_month | ||
FOR VALUES FROM ('2017', '1') TO ('2017', '2'); | ||
|
||
ALTER TABLE ONLY public.measurement_ym_y2017m01 ALTER COLUMN unitsales SET DEFAULT 5234; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters