ALTER TABLE logbook ADD COLUMN "steering_person" INTEGER NOT NULL DEFAULT 0 REFERENCES user(id); UPDATE logbook SET steering_person = shipmaster; CREATE TABLE "logbook_temp" ( "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "boat_id" INTEGER NOT NULL REFERENCES boat(id), "shipmaster" INTEGER NOT NULL REFERENCES user(id), "steering_person" INTEGER NOT NULL DEFAULT 1 REFERENCES user(id), "shipmaster_only_steering" boolean not null, "departure" datetime not null, "arrival" datetime, "destination" text, "distance_in_km" integer, "comments" text, "logtype" INTEGER REFERENCES logbook_type(id) ); INSERT INTO logbook_temp(id, boat_id, shipmaster, shipmaster_only_steering, departure, arrival, destination, distance_in_km, comments, logtype) SELECT id, boat_id, shipmaster, shipmaster_only_steering, COALESCE(departure, '2000-01-01 00:00:00'), arrival, destination, distance_in_km, comments, logtype FROM logbook; DROP TABLE logbook; ALTER TABLE logbook_temp RENAME TO logbook; INSERT INTO rower(rower_id, logbook_id) SELECT shipmaster, id FROM logbook; -- tmp ergo challenge stuff ALTER TABLE user ADD COLUMN dob text; ALTER TABLE user ADD COLUMN weight text; ALTER TABLE user ADD COLUMN sex text; ALTER TABLE user ADD COLUMN dirty_thirty text; ALTER TABLE user ADD COLUMN dirty_dozen text;