Skip to content

Commit b35d14f

Browse files
authored
Census layers (#450)
* Census layers * Updated migration
1 parent 4e831c3 commit b35d14f

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
BEGIN;
2+
3+
ALTER TABLE tl_census_datasets rename column dataset_name to name;
4+
ALTER TABLE tl_census_datasets add column description text;
5+
ALTER TABLE tl_census_datasets alter column year_min drop not null;
6+
ALTER TABLE tl_census_datasets alter column year_max drop not null;
7+
ALTER TABLE tl_census_datasets alter column url drop not null;
8+
9+
ALTER TABLE tl_census_sources rename column source_name to name;
10+
ALTER TABLE tl_census_sources add column description text;
11+
12+
CREATE TABLE tl_census_layers (
13+
id bigserial PRIMARY KEY,
14+
dataset_id bigint REFERENCES tl_census_datasets(id) not null,
15+
name text NOT NULL,
16+
description text,
17+
created_at timestamp without time zone DEFAULT now() NOT NULL,
18+
updated_at timestamp without time zone DEFAULT now() NOT NULL
19+
);
20+
CREATE INDEX ON tl_census_layers (name);
21+
CREATE INDEX ON tl_census_layers (dataset_id);
22+
23+
ALTER TABLE tl_census_geographies ADD COLUMN layer_id bigint REFERENCES tl_census_layers(id);
24+
ALTER TABLE tl_census_geographies DROP COLUMN layer_name;
25+
CREATE INDEX ON tl_census_geographies (layer_id);
26+
27+
COMMIT;

0 commit comments

Comments
 (0)