Migrate to SQLite3
We'll keep the door open for side-by-side support of Postgres in the background, but due to SQLite's type system quirks we cannot use the same DDL for both databases, so we would have to maintain two sets of DDL (schema init and schema migration scripts) at once. Interested future contributors can shoulder this maintenance burden if they so choose.
This commit is contained in:
+57
-61
@@ -2,18 +2,14 @@
|
||||
-- A "course" contains an uphill and downhill "route"
|
||||
-- (or inbound/outbound etc)
|
||||
|
||||
create schema "idz";
|
||||
|
||||
create type "idz_gender" as enum ('male', 'female');
|
||||
|
||||
create table "idz_profile" (
|
||||
"id" bigint primary key not null,
|
||||
"player_id" bigint not null
|
||||
"id" integer primary key not null,
|
||||
"player_id" integer not null
|
||||
references "aime_player"("id")
|
||||
on delete cascade,
|
||||
-- TODO shop_id
|
||||
"name" text not null,
|
||||
"lv" smallint not null,
|
||||
"lv" integer not null,
|
||||
"exp" integer not null,
|
||||
"fame" integer not null,
|
||||
"dpoint" integer not null,
|
||||
@@ -24,10 +20,10 @@ create table "idz_profile" (
|
||||
);
|
||||
|
||||
create table "idz_chara" (
|
||||
"id" bigint primary key not null
|
||||
"id" integer primary key not null
|
||||
references "idz_profile"("id")
|
||||
on delete cascade,
|
||||
"gender" "idz_gender" not null,
|
||||
"gender" text not null,
|
||||
"field_02" integer not null,
|
||||
"field_04" integer not null,
|
||||
"field_06" integer not null,
|
||||
@@ -40,18 +36,18 @@ create table "idz_chara" (
|
||||
);
|
||||
|
||||
create table "idz_course_plays" (
|
||||
"id" bigint primary key not null,
|
||||
"profile_id" bigint not null
|
||||
"id" integer primary key not null,
|
||||
"profile_id" integer not null
|
||||
references "idz_profile"("id")
|
||||
on delete cascade,
|
||||
"course_no" smallint not null,
|
||||
"course_no" integer not null,
|
||||
"count" integer not null,
|
||||
constraint "idz_course_plays_uq" unique ("profile_id", "course_no")
|
||||
);
|
||||
|
||||
create table "idz_car" (
|
||||
"id" bigint primary key not null,
|
||||
"profile_id" bigint not null
|
||||
"id" integer primary key not null,
|
||||
"profile_id" integer not null
|
||||
references "idz_profile"("id")
|
||||
on delete cascade,
|
||||
"selector" integer not null,
|
||||
@@ -73,22 +69,22 @@ create table "idz_car" (
|
||||
);
|
||||
|
||||
create table "idz_car_selection" (
|
||||
"id" bigint primary key not null
|
||||
"id" integer primary key not null
|
||||
references "idz_profile"("id")
|
||||
on delete cascade,
|
||||
"car_id" bigint not null
|
||||
"car_id" integer not null
|
||||
references "idz_car"("id")
|
||||
on delete cascade
|
||||
);
|
||||
|
||||
create table "idz_solo_mission_state" (
|
||||
"id" bigint primary key not null,
|
||||
"profile_id" bigint not null
|
||||
"id" integer primary key not null,
|
||||
"profile_id" integer not null
|
||||
references "idz_profile"("id")
|
||||
on delete cascade,
|
||||
"grid_no" smallint not null,
|
||||
"cell_no" smallint not null,
|
||||
"value" smallint not null,
|
||||
"grid_no" integer not null,
|
||||
"cell_no" integer not null,
|
||||
"value" integer not null,
|
||||
constraint "idz_solo_mission_state_uq" unique (
|
||||
"profile_id",
|
||||
"grid_no",
|
||||
@@ -97,32 +93,32 @@ create table "idz_solo_mission_state" (
|
||||
);
|
||||
|
||||
create table "idz_settings" (
|
||||
"id" bigint primary key not null
|
||||
"id" integer primary key not null
|
||||
references "idz_profile"("id")
|
||||
on delete cascade,
|
||||
"music" smallint not null,
|
||||
"pack" bigint not null,
|
||||
"paper_cup" smallint not null, -- Not a boolean, oddly enough
|
||||
"music" integer not null,
|
||||
"pack" integer not null,
|
||||
"paper_cup" integer not null, -- Not a boolean, oddly enough
|
||||
"gauges" integer not null
|
||||
);
|
||||
|
||||
create table "idz_story_state" (
|
||||
"id" bigint primary key not null
|
||||
"id" integer primary key not null
|
||||
references "idz_profile"("id")
|
||||
on delete cascade,
|
||||
"x" smallint not null,
|
||||
"y" smallint not null
|
||||
"x" integer not null,
|
||||
"y" integer not null
|
||||
);
|
||||
|
||||
create table "idz_story_cell_state" (
|
||||
"id" bigint primary key not null,
|
||||
"profile_id" bigint not null
|
||||
"id" integer primary key not null,
|
||||
"profile_id" integer not null
|
||||
references "idz_profile"("id")
|
||||
on delete cascade,
|
||||
"row_no" integer not null,
|
||||
"col_no" integer not null,
|
||||
"a" smallint not null,
|
||||
"b" smallint not null,
|
||||
"a" integer not null,
|
||||
"b" integer not null,
|
||||
constraint "idz_story_cell_state_uq" unique (
|
||||
"profile_id",
|
||||
"row_no",
|
||||
@@ -131,7 +127,7 @@ create table "idz_story_cell_state" (
|
||||
);
|
||||
|
||||
create table "idz_free_car" (
|
||||
"id" bigint primary key not null
|
||||
"id" integer primary key not null
|
||||
references "idz_profile"("id")
|
||||
on delete cascade,
|
||||
"valid_from" timestamp not null
|
||||
@@ -141,29 +137,29 @@ create table "idz_free_car" (
|
||||
-- Times are stored as floating-point seconds
|
||||
|
||||
create table "idz_ta_result" (
|
||||
"id" bigint primary key not null,
|
||||
"profile_id" bigint not null
|
||||
"id" integer primary key not null,
|
||||
"profile_id" integer not null
|
||||
references "idz_profile"("id")
|
||||
on delete cascade,
|
||||
"route_no" smallint not null,
|
||||
"route_no" integer not null,
|
||||
"total_time" float not null,
|
||||
"section_times" text not null,
|
||||
"flags" smallint not null,
|
||||
"grade" smallint not null,
|
||||
"flags" integer not null,
|
||||
"grade" integer not null,
|
||||
"car_selector" integer not null,
|
||||
"timestamp" timestamp not null
|
||||
);
|
||||
|
||||
create table "idz_ta_best" (
|
||||
"id" bigint primary key not null,
|
||||
"profile_id" bigint not null
|
||||
"id" integer primary key not null,
|
||||
"profile_id" integer not null
|
||||
references "idz_profile"("id")
|
||||
on delete cascade,
|
||||
"route_no" smallint not null,
|
||||
"route_no" integer not null,
|
||||
"total_time" float not null,
|
||||
"section_times" text not null,
|
||||
"flags" smallint not null,
|
||||
"grade" smallint not null, -- TODO enum
|
||||
"flags" integer not null,
|
||||
"grade" integer not null, -- TODO enum
|
||||
"car_selector" integer not null,
|
||||
"timestamp" timestamp not null,
|
||||
constraint "idz_ta_best_uq" unique ("profile_id", "route_no")
|
||||
@@ -172,11 +168,11 @@ create table "idz_ta_best" (
|
||||
-- TODO ta_section_best
|
||||
|
||||
create table "idz_background_unlock" (
|
||||
"id" bigint primary key not null,
|
||||
"profile_id" bigint not null
|
||||
"id" integer primary key not null,
|
||||
"profile_id" integer not null
|
||||
references "idz_profile"("id")
|
||||
on delete cascade,
|
||||
"background_no" smallint not null,
|
||||
"background_no" integer not null,
|
||||
constraint "idz_background_unlock_uq" unique (
|
||||
"profile_id",
|
||||
"background_no"
|
||||
@@ -184,48 +180,48 @@ create table "idz_background_unlock" (
|
||||
);
|
||||
|
||||
create table "idz_title_unlock" (
|
||||
"id" bigint primary key not null,
|
||||
"profile_id" bigint not null
|
||||
"id" integer primary key not null,
|
||||
"profile_id" integer not null
|
||||
references "idz_profile"("id")
|
||||
on delete cascade,
|
||||
"title_no" smallint not null,
|
||||
"title_no" integer not null,
|
||||
constraint "idz_title_unlock_uq" unique ("profile_id", "title_no")
|
||||
);
|
||||
|
||||
create table "idz_unlocks" (
|
||||
"id" bigint primary key not null
|
||||
"id" integer primary key not null
|
||||
references "idz_profile"("id")
|
||||
on delete cascade,
|
||||
"cup" smallint not null,
|
||||
"cup" integer not null,
|
||||
"gauges" integer not null,
|
||||
"music" integer not null,
|
||||
"last_mileage_reward" integer not null
|
||||
);
|
||||
|
||||
create table "idz_team" (
|
||||
"id" bigint primary key not null,
|
||||
"id" integer primary key not null,
|
||||
"ext_id" integer not null,
|
||||
"name" text not null,
|
||||
"name_bg" smallint not null,
|
||||
"name_fx" smallint not null,
|
||||
"name_bg" integer not null,
|
||||
"name_fx" integer not null,
|
||||
"register_time" timestamp not null,
|
||||
constraint "idz_team_uq" unique ("ext_id")
|
||||
);
|
||||
|
||||
create table "idz_team_auto" (
|
||||
"id" bigint primary key not null
|
||||
"id" integer primary key not null
|
||||
references "idz_team"("id")
|
||||
on delete cascade,
|
||||
"serial_no" smallint not null,
|
||||
"name_idx" smallint not null,
|
||||
"serial_no" integer not null,
|
||||
"name_idx" integer not null,
|
||||
constraint "idz_team_auto_uq" unique ("serial_no", "name_idx")
|
||||
);
|
||||
|
||||
create table "idz_team_member" (
|
||||
"id" bigint primary key not null
|
||||
"id" integer primary key not null
|
||||
references "idz_profile"("id")
|
||||
on delete cascade,
|
||||
"team_id" bigint not null
|
||||
"team_id" integer not null
|
||||
references "idz_team"("id")
|
||||
on delete cascade,
|
||||
"join_time" timestamp not null,
|
||||
@@ -233,10 +229,10 @@ create table "idz_team_member" (
|
||||
);
|
||||
|
||||
create table "idz_team_reservation" (
|
||||
"id" bigint primary key not null
|
||||
"id" integer primary key not null
|
||||
references "aime_player"("id")
|
||||
on delete cascade,
|
||||
"team_id" bigint not null
|
||||
"team_id" integer not null
|
||||
references "idz_team"("id")
|
||||
on delete cascade,
|
||||
"join_time" timestamp not null,
|
||||
|
||||
Reference in New Issue
Block a user