aboutsummaryrefslogtreecommitdiff
path: root/db/migrations/20260828000000_add_fit_path.sql
blob: 7f34ab8c8c15399e61ec1d619fc656c99f165d27 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

-- migrate:up
ALTER TABLE rides ADD COLUMN fit_path TEXT NOT NULL DEFAULT '';

-- 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'))
);
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)
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 FROM rides;
DROP TABLE rides;
ALTER TABLE rides_new RENAME TO rides;