hacky-ruadat/staging-diff.sql

57 lines
3.6 KiB
SQL

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;
UPDATE user SET dob = '1993', weight = '70', sex = 'f' WHERE name like 'Marie Birner';
UPDATE user SET dob = '1986', weight = '58', sex = 'f' WHERE name like 'Sandra Sollberger';
UPDATE user SET dob = '1999', weight = '70', sex = 'm' WHERE name like 'Raphael Eichhorn';
UPDATE user SET dob = '1979', weight = '78', sex = 'm' WHERE name like 'Daniel Eichhorn';
UPDATE user SET dob = '1958', weight = '112', sex = 'm' WHERE name like 'Christian Gusenbauer';
UPDATE user SET dob = '1994', weight = '60', sex = 'm' WHERE name like 'Philipp Baillon';
UPDATE user SET dob = '1971', weight = '77', sex = 'm' WHERE name like 'Manfred Meindl';
UPDATE user SET dob = '1984', weight = '72', sex = 'm' WHERE name like 'Thomas Hoffelner';
UPDATE user SET dob = '1982', weight = '65', sex = 'f' WHERE name like 'Bettina Fürlinger';
UPDATE user SET dob = '1965', weight = '85', sex = 'm' WHERE name like 'Thomas Klima';
UPDATE user SET dob = '1997', weight = '65', sex = 'm' WHERE name like 'Philipp Hofer';
UPDATE user SET dob = '1969', weight = '77', sex = 'f' WHERE name like 'Claudia Jagersberger';
UPDATE user SET dob = '1999', weight = '85', sex = 'm' WHERE name like 'Martin Kugler';
UPDATE user SET dob = '1978', weight = '72', sex = 'f' WHERE name like 'Eva-Maria Gruber';
UPDATE user SET dob = '1993', weight = '100', sex = 'm' WHERE name like 'Niklas Sageder';
UPDATE user SET dob = '2001', weight = '', sex = 'f' WHERE name like 'Marika Rodinger';
UPDATE user SET dob = '2005', weight = '82', sex = 'm' WHERE name like 'Erik Rodinger';
UPDATE user SET dob = '1967', weight = '99', sex = 'm' WHERE name like 'Michael Rodinger';
UPDATE user SET dob = '2001', weight = '', sex = 'm' WHERE name like 'Alaa Almousa';
UPDATE user SET dob = '1994', weight = '72', sex = 'm' WHERE name like 'Stephan Siegl';
UPDATE user SET dob = '2007', weight = '68', sex = 'f' WHERE name like 'Caroline Schwendinger';
UPDATE user SET dob = '2007', weight = '50', sex = 'f' WHERE name like 'Daria Danner';
UPDATE user SET dob = '2001', weight = '58', sex = 'f' WHERE name like 'Edith Steinacker';
UPDATE user SET dob = '2002', weight = '', sex = 'm' WHERE name like 'Max Knauseder';
UPDATE user SET dob = '2005', weight = '', sex = 'f' WHERE name like 'Larissa Freimuth';
UPDATE user SET dob = '1980', weight = '53', sex = 'f' WHERE name like 'Sylvia Ecker';