aboutsummaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorMartin Kagamino Lehoux <martin@lehoux.net>2026-08-28 10:19:15 +0200
committerMartin Kagamino Lehoux <martin@lehoux.net>2026-08-28 10:19:15 +0200
commit10806900a46b4eba197af9fc768928c57bd33982 (patch)
treec4e69e242831dcdce962eb6e227a41557e126f14 /db
parent843fd11774531a4fd22456093b112506cbffbc18 (diff)
Add touring ride type for cyclotourisme
Diffstat (limited to 'db')
-rw-r--r--db/migrations/20260829000000_add_touring_ride_type.sql55
-rw-r--r--db/schema.sql5
2 files changed, 58 insertions, 2 deletions
diff --git a/db/migrations/20260829000000_add_touring_ride_type.sql b/db/migrations/20260829000000_add_touring_ride_type.sql
new file mode 100644
index 0000000..dc1555d
--- /dev/null
+++ b/db/migrations/20260829000000_add_touring_ride_type.sql
@@ -0,0 +1,55 @@
+-- migrate:up
+CREATE TABLE rides_new (
+ id integer primary key,
+ external_id text unique not null,
+ gpx_path text not null,
+ name text not null,
+ type text not null,
+ start_date text not null,
+ distance_m real not null,
+ external_moving_time_s integer not null,
+ elapsed_time_s integer not null,
+ total_elevation_gain_m real not null,
+ average_speed_mps real not null,
+ 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')),
+ cotacol_score real,
+ cotacol_algo_version text,
+ moving_time_s integer,
+ moving_time_algo_version text,
+ bike_type TEXT NOT NULL DEFAULT '' CHECK (bike_type IN ('', 'road', 'mtb')),
+ ride_type TEXT NOT NULL DEFAULT '' CHECK (ride_type IN ('', 'training', 'indoor', 'race', 'transport', 'touring')),
+ fit_path TEXT NOT NULL DEFAULT ''
+);
+INSERT INTO rides_new (id, external_id, gpx_path, name, type, start_date, distance_m, external_moving_time_s, elapsed_time_s, total_elevation_gain_m, average_speed_mps, created_at, updated_at, cotacol_score, cotacol_algo_version, moving_time_s, moving_time_algo_version, bike_type, ride_type, fit_path)
+SELECT id, external_id, gpx_path, name, type, start_date, distance_m, external_moving_time_s, elapsed_time_s, total_elevation_gain_m, average_speed_mps, created_at, updated_at, cotacol_score, cotacol_algo_version, moving_time_s, moving_time_algo_version, bike_type, ride_type, fit_path FROM rides;
+DROP TABLE rides;
+ALTER TABLE rides_new RENAME TO rides;
+
+-- migrate:down
+CREATE TABLE rides_new (
+ id integer primary key,
+ external_id text unique not null,
+ gpx_path text not null,
+ name text not null,
+ type text not null,
+ start_date text not null,
+ distance_m real not null,
+ external_moving_time_s integer not null,
+ elapsed_time_s integer not null,
+ total_elevation_gain_m real not null,
+ average_speed_mps real not null,
+ 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')),
+ cotacol_score real,
+ cotacol_algo_version text,
+ moving_time_s integer,
+ moving_time_algo_version text,
+ bike_type TEXT NOT NULL DEFAULT '' CHECK (bike_type IN ('', 'road', 'mtb')),
+ ride_type TEXT NOT NULL DEFAULT '' CHECK (ride_type IN ('', 'training', 'indoor', 'race', 'transport')),
+ fit_path TEXT NOT NULL DEFAULT ''
+);
+INSERT INTO rides_new (id, external_id, gpx_path, name, type, start_date, distance_m, external_moving_time_s, elapsed_time_s, total_elevation_gain_m, average_speed_mps, created_at, updated_at, cotacol_score, cotacol_algo_version, moving_time_s, moving_time_algo_version, bike_type, ride_type, fit_path)
+SELECT id, external_id, gpx_path, name, type, start_date, distance_m, external_moving_time_s, elapsed_time_s, total_elevation_gain_m, average_speed_mps, created_at, updated_at, cotacol_score, cotacol_algo_version, moving_time_s, moving_time_algo_version, bike_type, ride_type, fit_path FROM rides WHERE ride_type IN ('', 'training', 'indoor', 'race', 'transport');
+DROP TABLE rides;
+ALTER TABLE rides_new RENAME TO rides;
diff --git a/db/schema.sql b/db/schema.sql
index a22e98f..79f4c62 100644
--- a/db/schema.sql
+++ b/db/schema.sql
@@ -13,7 +13,7 @@ CREATE TABLE rides (
average_speed_mps real not null,
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'))
-, cotacol_score real, cotacol_algo_version text, moving_time_s integer, moving_time_algo_version text, bike_type TEXT NOT NULL DEFAULT '' CHECK (bike_type IN ('', 'road', 'mtb')), ride_type TEXT NOT NULL DEFAULT '' CHECK (ride_type IN ('', 'training', 'indoor', 'race', 'transport')), fit_path TEXT NOT NULL DEFAULT '');
+, cotacol_score real, cotacol_algo_version text, moving_time_s integer, moving_time_algo_version text, bike_type TEXT NOT NULL DEFAULT '' CHECK (bike_type IN ('', 'road', 'mtb')), ride_type TEXT NOT NULL DEFAULT '' CHECK (ride_type IN ('', 'training', 'indoor', 'race', 'transport', 'touring')), fit_path TEXT NOT NULL DEFAULT '');
CREATE TABLE official_climbs (
id integer primary key,
name text not null,
@@ -43,4 +43,5 @@ INSERT INTO "schema_migrations" (version) VALUES
('20260821000000'),
('20260823000000'),
('20260827000000'),
- ('20260828000000');
+ ('20260828000000'),
+ ('20260829000000');