diff options
Diffstat (limited to 'db')
| -rw-r--r-- | db/migrations/20260827000000_mountain_pass_category.sql | 16 | ||||
| -rw-r--r-- | db/schema.sql | 19 |
2 files changed, 26 insertions, 9 deletions
diff --git a/db/migrations/20260827000000_mountain_pass_category.sql b/db/migrations/20260827000000_mountain_pass_category.sql new file mode 100644 index 0000000..0bb3181 --- /dev/null +++ b/db/migrations/20260827000000_mountain_pass_category.sql @@ -0,0 +1,16 @@ +-- migrate:up +ALTER TABLE mountain_passes ADD COLUMN category TEXT NOT NULL DEFAULT 'unknown' CHECK (category IN ('road', 'track', 'path', 'hiking', 'unknown')); + +-- migrate:down +CREATE TABLE mountain_passes_backup ( + id integer primary key, + osm_id integer unique not null, + name text, + elevation integer, + latitude real not null, + longitude real not null +); +INSERT INTO mountain_passes_backup (id, osm_id, name, elevation, latitude, longitude) +SELECT id, osm_id, name, elevation, latitude, longitude FROM mountain_passes; +DROP TABLE mountain_passes; +ALTER TABLE mountain_passes_backup RENAME TO mountain_passes; diff --git a/db/schema.sql b/db/schema.sql index 9713add..8ae55f7 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -1,12 +1,4 @@ CREATE TABLE IF NOT EXISTS "schema_migrations" (version varchar(255) primary key); -CREATE TABLE IF NOT EXISTS "mountain_passes" ( - id integer primary key, - osm_id integer unique not null, - name text, - elevation integer, - latitude real not null, - longitude real not null -); CREATE TABLE rides ( id integer primary key, external_id text unique not null, @@ -32,6 +24,14 @@ CREATE TABLE official_climbs ( created_at text not null default (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')), updated_at text not null default (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')) ); +CREATE TABLE IF NOT EXISTS "mountain_passes" ( + id integer primary key, + osm_id integer unique not null, + name text, + elevation integer, + latitude real not null, + longitude real not null +, category TEXT NOT NULL DEFAULT 'unknown' CHECK (category IN ('road', 'track', 'path', 'hiking', 'unknown'))); -- Dbmate schema migrations INSERT INTO "schema_migrations" (version) VALUES ('20250802140659'), @@ -41,4 +41,5 @@ INSERT INTO "schema_migrations" (version) VALUES ('20260813000000'), ('20260820184307'), ('20260821000000'), - ('20260823000000'); + ('20260823000000'), + ('20260827000000'); |
