Skip to content
This repository has been archived by the owner on Dec 13, 2024. It is now read-only.

Commit

Permalink
add mysql tables
Browse files Browse the repository at this point in the history
  • Loading branch information
sfomuseumbot committed Mar 11, 2024
1 parent 4d86279 commit 45ab89d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tables/geojson.mysql.schema
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CREATE TABLE IF NOT EXISTS geojson (
id BIGINT UNSIGNED,
alt VARCHAR(255) NOT NULL,
body LONGBLOB NOT NULL,
lastmodified INT NOT NULL,
UNIQUE KEY id_alt (id, alt),
KEY lastmodified (lastmodified)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
3 changes: 3 additions & 0 deletions tables/whosonfirst.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package tables

const WHOSONFIRST_TABLE_NAME string = "whosonfirst"
30 changes: 30 additions & 0 deletions tables/whosonfirst.mysql.schema
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
CREATE TABLE IF NOT EXISTS whosonfirst (
id BIGINT UNSIGNED PRIMARY KEY,
properties JSON NOT NULL,
geometry GEOMETRY NOT NULL,
centroid POINT NOT NULL COMMENT 'This is not necessary a math centroid',
lastmodified INT NOT NULL,
parent_id BIGINT GENERATED ALWAYS AS (JSON_UNQUOTE(JSON_EXTRACT(properties,'$."wof:parent_id"'))) VIRTUAL,
placetype VARCHAR(64) GENERATED ALWAYS AS (JSON_UNQUOTE(JSON_EXTRACT(properties,'$."wof:placetype"'))) VIRTUAL,
is_current TINYINT GENERATED ALWAYS AS (JSON_CONTAINS_PATH(properties, 'one', '$."mz:is_current"') AND JSON_UNQUOTE(JSON_EXTRACT(properties,'$."mz:is_current"'))) VIRTUAL,
is_nullisland TINYINT GENERATED ALWAYS AS (JSON_CONTAINS_PATH(properties, 'one', '$."mz:is_nullisland"') AND JSON_LENGTH(JSON_EXTRACT(properties, '$."mz:is_nullisland"'))) VIRTUAL,
is_approximate TINYINT GENERATED ALWAYS AS (JSON_CONTAINS_PATH(properties, 'one', '$."mz:is_approximate"') AND JSON_LENGTH(JSON_EXTRACT(properties, '$."mz:is_approximate"'))) VIRTUAL,
is_ceased TINYINT GENERATED ALWAYS AS (JSON_CONTAINS_PATH(properties, 'one', '$."edtf:cessation"') AND JSON_UNQUOTE(JSON_EXTRACT(properties,'$."edtf:cessation"')) != "" AND JSON_UNQUOTE(JSON_EXTRACT(properties,'$."edtf:cessation"')) != "open" AND json_unquote(json_extract(properties,'$."edtf:cessation"')) != "uuuu") VIRTUAL,
is_deprecated TINYINT GENERATED ALWAYS AS (JSON_CONTAINS_PATH(properties, 'one', '$."edtf:deprecated"') AND JSON_UNQUOTE(JSON_EXTRACT(properties,'$."edtf:deprecated"')) != "" AND json_unquote(json_extract(properties,'$."edtf:deprecated"')) != "uuuu") VIRTUAL,
is_superseded TINYINT GENERATED ALWAYS AS (JSON_LENGTH(JSON_EXTRACT(properties, '$."wof:superseded_by"')) > 0) VIRTUAL,
is_superseding TINYINT GENERATED ALWAYS AS (JSON_LENGTH(JSON_EXTRACT(properties, '$."wof:supersedes"')) > 0) VIRTUAL,
date_upper DATE GENERATED ALWAYS AS (JSON_UNQUOTE(JSON_EXTRACT(properties, '$."date:cessation_upper"'))) VIRTUAL,
date_lower DATE GENERATED ALWAYS AS (JSON_UNQUOTE(JSON_EXTRACT(properties, '$."date:inception_lower"'))) VIRTUAL,
KEY parent_id (parent_id),
KEY placetype (placetype),
KEY is_current (is_current),
KEY is_nullisland (is_nullisland),
KEY is_approximate (is_approximate),
KEY is_deprecated (is_deprecated),
KEY is_superseded (is_superseded),
KEY is_superseding (is_superseding),
KEY date_upper (date_upper),
KEY date_lower (date_lower),
SPATIAL KEY idx_geometry (geometry),
SPATIAL KEY idx_centroid (centroid)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

0 comments on commit 45ab89d

Please sign in to comment.