diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-23 21:35:59 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-23 21:35:59 +0200 |
| commit | 08fdd6964fd9ef29356420b035e2d186546f674a (patch) | |
| tree | 812565b5ca57405a5b36b2d7edfab983f6f079d4 /db | |
| parent | 2d8503cafb9f63ca4cb63f041281987f9a63f16a (diff) | |
Add hardcore ride categorisation with bike and ride types
Diffstat (limited to 'db')
| -rw-r--r-- | db/migrations/20260823000000_ride_categories.sql | 29 | ||||
| -rw-r--r-- | db/schema.sql | 5 |
2 files changed, 32 insertions, 2 deletions
diff --git a/db/migrations/20260823000000_ride_categories.sql b/db/migrations/20260823000000_ride_categories.sql new file mode 100644 index 0000000..0ae4f1b --- /dev/null +++ b/db/migrations/20260823000000_ride_categories.sql @@ -0,0 +1,29 @@ +-- migrate:up +ALTER TABLE rides ADD COLUMN bike_type TEXT NOT NULL DEFAULT '' CHECK (bike_type IN ('', 'road', 'mtb')); +ALTER TABLE rides ADD COLUMN ride_type TEXT NOT NULL DEFAULT '' CHECK (ride_type IN ('', 'training', 'indoor', 'race', 'transport')); + +-- migrate:down +-- SQLite does not support DROP COLUMN with CHECK in older versions, recreate table without columns +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 +); +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) +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 FROM rides; +DROP TABLE rides; +ALTER TABLE rides_new RENAME TO rides; diff --git a/db/schema.sql b/db/schema.sql index 60505bb..9713add 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -21,7 +21,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); +, 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'))); CREATE TABLE official_climbs ( id integer primary key, name text not null, @@ -40,4 +40,5 @@ INSERT INTO "schema_migrations" (version) VALUES ('20260807000000'), ('20260813000000'), ('20260820184307'), - ('20260821000000'); + ('20260821000000'), + ('20260823000000'); |
