-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
218 additions
and
1 deletion.
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
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,41 @@ | ||
-- tables pour gérer les référentiels géographiques points (PK/PR, ..) | ||
-- - ref_geo.bib_points_types | ||
-- - ref_geo.l_points | ||
|
||
CREATE TABLE ref_geo.bib_points_types ( | ||
id_type SERIAL NOT NULL, | ||
type_name character varying(200) NOT NULL, | ||
type_code character varying(25) NOT NULL, | ||
type_desc text, | ||
ref_name character varying(200), | ||
ref_version integer, | ||
num_version character varying(50), | ||
meta_create_date timestamp without time zone, | ||
meta_update_date timestamp without time zone, | ||
CONSTRAINT pk_ref_geo_bib_points_types_id_type PRIMARY KEY (id_type), | ||
UNIQUE(type_code) | ||
); | ||
|
||
-- table des linéaires (tronçon de route, etc..) | ||
|
||
CREATE TABLE ref_geo.l_points ( | ||
id_point SERIAL NOT NULL, | ||
id_type INTEGER NOT NULL, | ||
point_name character varying(250) NOT NULL, | ||
point_code character varying(25) NOT NULL, | ||
enable BOOLEAN NOT NULL DEFAULT (TRUE), | ||
geom GEOMETRY(GEOMETRY, 2154), | ||
geojson_4326 VARCHAR, | ||
source character varying(250), | ||
additional_data jsonb NULL, | ||
meta_create_date timestamp without time zone, | ||
meta_update_date timestamp without time zone, | ||
|
||
UNIQUE (id_type, point_code), | ||
|
||
CONSTRAINT pk_ref_geo_l_points_id_point PRIMARY KEY (id_point), | ||
CONSTRAINT fk_ref_geo_l_points_id_type FOREIGN KEY (id_type) | ||
REFERENCES ref_geo.bib_points_types(id_type) | ||
ON UPDATE CASCADE ON DELETE NO ACTION | ||
); | ||
|
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 @@ | ||
-- cor_areas | ||
|
||
CREATE TABLE ref_geo.cor_areas ( | ||
id_area_group integer, | ||
id_area integer | ||
); | ||
|
||
ALTER TABLE ref_geo.cor_areas | ||
ADD CONSTRAINT fk_ref_geo_cor_areas_id_area_group FOREIGN KEY (id_area_group) | ||
REFERENCES ref_geo.l_areas(id_area) | ||
ON UPDATE CASCADE ON DELETE CASCADE; | ||
|
||
ALTER TABLE ref_geo.cor_areas | ||
ADD CONSTRAINT fk_ref_geo_cor_areas_id_area FOREIGN KEY (id_area) | ||
REFERENCES ref_geo.l_areas(id_area) | ||
ON UPDATE CASCADE ON DELETE CASCADE; | ||
|
||
CREATE INDEX ref_geo_cor_areas_id_area ON ref_geo.cor_areas USING btree(id_area); | ||
CREATE INDEX ref_geo_cor_areas_id_area_group ON ref_geo.cor_areas USING btree(id_area_group); | ||
|
||
|
||
-- cor_areas | ||
|
||
CREATE TABLE ref_geo.cor_linear_area ( | ||
id_linear integer, | ||
id_area integer | ||
); | ||
|
||
ALTER TABLE ref_geo.cor_linear_area | ||
ADD CONSTRAINT fk_ref_geo_cor_linear_id_area_group FOREIGN KEY (id_area) | ||
REFERENCES ref_geo.l_areas(id_area) | ||
ON UPDATE CASCADE ON DELETE CASCADE; | ||
|
||
ALTER TABLE ref_geo.cor_linear_area | ||
ADD CONSTRAINT fk_ref_geo_cor_linear_id_lineair_group FOREIGN KEY (id_linear) | ||
REFERENCES ref_geo.l_linears(id_linear) | ||
ON UPDATE CASCADE ON DELETE CASCADE; | ||
|
||
CREATE INDEX ref_geo_cor_linear_area_id_area ON ref_geo.cor_linear_area USING btree(id_area); | ||
CREATE INDEX ref_geo_cor_linear_area_id_linear ON ref_geo.cor_linear_area USING btree(id_linear); |
37 changes: 37 additions & 0 deletions
37
src/ref_geo/migrations/versions/795f6ea8ec45_cor_linear_area.py
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,37 @@ | ||
"""cor_areas & cor_linear_areas | ||
Revision ID: 795f6ea8ec45 | ||
Revises: dea1645de8c0 | ||
Create Date: 2023-08-02 11:48:06.329936 | ||
""" | ||
|
||
import sqlalchemy as sa | ||
import importlib | ||
|
||
from alembic import op | ||
from sqlalchemy.sql import text | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = "795f6ea8ec45" | ||
down_revision = "dea1645de8c0" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
stmt = text(importlib.resources.read_text("ref_geo.migrations.data", "ref_geo_cor.sql")) | ||
op.get_bind().execute(stmt) | ||
pass | ||
|
||
|
||
def downgrade(): | ||
op.get_bind().execute( | ||
""" | ||
DROP TABLE ref_geo.cor_linear_area; | ||
DROP TABLE ref_geo.cor_areas; | ||
""" | ||
) | ||
|
||
pass |
38 changes: 38 additions & 0 deletions
38
src/ref_geo/migrations/versions/dea1645de8c0_ref_geo_point.py
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,38 @@ | ||
""" Référentiel point, cor (area, linear, point) | ||
Revision ID: dea1645de8c0 | ||
Revises: f7374cd6e38d | ||
Create Date: 2023-07-27 12:13:01.748452 | ||
""" | ||
import importlib | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
from sqlalchemy.sql import text | ||
from ref_geo.utils import ( | ||
get_local_srid, | ||
) | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "dea1645de8c0" | ||
down_revision = "f7374cd6e38d" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
stmt = text(importlib.resources.read_text("ref_geo.migrations.data", "ref_geo_point.sql")) | ||
op.get_bind().execute(stmt, {"local_srid": get_local_srid(op.get_bind())}) | ||
|
||
pass | ||
|
||
|
||
def downgrade(): | ||
op.get_bind().execute( | ||
""" | ||
DROP TABLE ref_geo.bib_points_types; | ||
DROP TABLE ref_geo.l_points; | ||
""" | ||
) | ||
pass |
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