X-Git-Url: https://git.sesse.net/?p=remoteglot;a=blobdiff_plain;f=upgrade.sql;fp=upgrade.sql;h=37492e48d02031f42b3452affa802620d9b68618;hp=0000000000000000000000000000000000000000;hb=311ed98a1cf3eefa25779aa8a67b8532cb619793;hpb=c0f94f3012b32944dda0e2fa2ca386b7640824d8 diff --git a/upgrade.sql b/upgrade.sql new file mode 100644 index 0000000..37492e4 --- /dev/null +++ b/upgrade.sql @@ -0,0 +1,13 @@ +BEGIN; +ALTER TABLE scores ADD COLUMN score_type varchar; +ALTER TABLE scores ADD COLUMN score_value integer; +ALTER TABLE scores ALTER COLUMN plot_score DROP NOT NULL; +ALTER TABLE scores ALTER COLUMN short_score DROP NOT NULL; +UPDATE scores SET score_type='d',plot_score=NULL,short_score=NULL WHERE short_score='TB draw'; +UPDATE scores SET score_type='cp',score_value=0,plot_score=NULL,short_score=NULL WHERE short_score=' 0.00'; +UPDATE scores SET score_type='m',score_value=substr(short_score,2)::integer,plot_score=NULL,short_score=NULL WHERE short_score LIKE 'M%'; +UPDATE scores SET score_type='cp',score_value=REPLACE(short_score, '.', '')::integer,plot_score=NULL,short_score=NULL WHERE short_score IS NOT NULL; +ALTER TABLE scores DROP COLUMN plot_score; +ALTER TABLE scores DROP COLUMN short_score; +ALTER TABLE scores ALTER COLUMN score_type SET NOT NULL; +COMMIT;