-- Migration: 0003_fix_trainings_id -- Description: Fix trainings table to use proper SQLite autoincrement ID -- Drop the existing trainings table (data will be lost) DROP TABLE IF EXISTS trainings; -- Recreate with proper SQLite syntax CREATE TABLE trainings ( id INTEGER PRIMARY KEY AUTOINCREMENT, date DATE NOT NULL, trainer VARCHAR(100), created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); -- Also fix exercises table if it exists DROP TABLE IF EXISTS exercises; CREATE TABLE exercises ( id INTEGER PRIMARY KEY AUTOINCREMENT, training_id INTEGER NOT NULL, name VARCHAR(255) NOT NULL, splitted_weight BOOLEAN DEFAULT 0, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (training_id) REFERENCES trainings(id) ON DELETE CASCADE ); -- Fix approaches table if it exists DROP TABLE IF EXISTS approaches; CREATE TABLE approaches ( id INTEGER PRIMARY KEY AUTOINCREMENT, exercise_id INTEGER NOT NULL, weight REAL, reps INTEGER, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (exercise_id) REFERENCES exercises(id) ON DELETE CASCADE ); INSERT INTO schema_migrations (version) VALUES ('0003_fix_trainings_id');