Created
January 14, 2018 01:43
-
-
Save jyutzler/f1efd090cbc937684c2011a9d0cf9a0a to your computer and use it in GitHub Desktop.
Migrate versions of GPKG-RTE
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
create table t1 as select * from gpkgext_relations; | |
drop table gpkgext_relations; | |
CREATE TABLE 'gpkgext_relations' ( | |
id INTEGER PRIMARY KEY AUTOINCREMENT, | |
geospatial_table_name TEXT NOT NULL, | |
geospatial_primary_column TEXT NOT NULL DEFAULT 'id', | |
attributes_table_name TEXT NOT NULL, | |
attributes_primary_column TEXT NOT NULL DEFAULT 'id', | |
relation_name TEXT NOT NULL, | |
mapping_table_name TEXT NOT NULL UNIQUE, | |
cardinality TEXT NOT NULL CHECK( cardinality in ('many-to-many','many-to-one','one-to-many')) | |
); | |
insert into gpkgext_relations select id, | |
base_table_name as geospatial_table_name, | |
base_primary_column as geospatial_primary_column, | |
attribute_table_name as attributes_table_name, | |
attribute_primary_column as attributes_primary_column, | |
relation_name, mapping_table_name, cardinality | |
from t1; | |
create table t1 as select * from cats_mapping; | |
drop table cats_mapping; | |
create table cats_mapping ( | |
geospatial_id INTEGER NOT NULL, | |
attributes_id INTEGER NOT NULL | |
); | |
insert into cats_mapping select base_id as geospatial_id, | |
attribute_id as attributes_id from t1; | |
drop table t1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment