Store array colums as CSV text
This is in preparation for a transition to SQLite, which sadly does not support array-valued columns (or indeed have much of a type system in general).
This commit is contained in:
+3
-3
@@ -57,7 +57,7 @@ create table "idz_car" (
|
||||
"selector" integer not null,
|
||||
"field_00" integer not null,
|
||||
"field_02" integer not null,
|
||||
"field_04" integer[] not null,
|
||||
"field_04" text not null,
|
||||
"field_46" integer not null,
|
||||
"field_48" integer not null,
|
||||
"field_4a" integer not null,
|
||||
@@ -147,7 +147,7 @@ create table "idz_ta_result" (
|
||||
on delete cascade,
|
||||
"route_no" smallint not null,
|
||||
"total_time" float not null,
|
||||
"section_times" float[] not null,
|
||||
"section_times" text not null,
|
||||
"flags" smallint not null,
|
||||
"grade" smallint not null,
|
||||
"car_selector" integer not null,
|
||||
@@ -161,7 +161,7 @@ create table "idz_ta_best" (
|
||||
on delete cascade,
|
||||
"route_no" smallint not null,
|
||||
"total_time" float not null,
|
||||
"section_times" float[] not null,
|
||||
"section_times" text not null,
|
||||
"flags" smallint not null,
|
||||
"grade" smallint not null, -- TODO enum
|
||||
"car_selector" integer not null,
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
create table "meta" ("schemaver" integer not null);
|
||||
insert into "meta" values (5);
|
||||
insert into "meta" values (6);
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
alter table "idz_car" rename column "field_04" to "tmp";
|
||||
alter table "idz_car" add column "field_04" text;
|
||||
update "idz_car" set "field_04" = array_to_string("tmp", ',');
|
||||
alter table "idz_car" alter column "field_04" set not null;
|
||||
alter table "idz_car" drop column "tmp";
|
||||
|
||||
alter table "idz_ta_result" rename column "section_times" to "tmp";
|
||||
alter table "idz_ta_result" add column "section_times" text;
|
||||
update "idz_ta_result" set "section_times" = array_to_string("tmp", ',');
|
||||
alter table "idz_ta_result" alter column "section_times" set not null;
|
||||
alter table "idz_ta_result" drop column "tmp";
|
||||
|
||||
alter table "idz_ta_best" rename column "section_times" to "tmp";
|
||||
alter table "idz_ta_best" add column "section_times" text;
|
||||
update "idz_ta_best" set "section_times" = array_to_string("tmp", ',');
|
||||
alter table "idz_ta_best" alter column "section_times" set not null;
|
||||
alter table "idz_ta_best" drop column "tmp";
|
||||
|
||||
update "meta" set "schemaver" = 6;
|
||||
Reference in New Issue
Block a user