Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jyutzler
Created January 14, 2018 01:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jyutzler/f1efd090cbc937684c2011a9d0cf9a0a to your computer and use it in GitHub Desktop.
Save jyutzler/f1efd090cbc937684c2011a9d0cf9a0a to your computer and use it in GitHub Desktop.
Migrate versions of GPKG-RTE
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