minime/schema/init/idz.sql
Tau 072d70b42a 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.
2019-11-06 17:28:30 -05:00

241 lines
6.9 KiB
SQL

-- Terminology:
-- A "course" contains an uphill and downhill "route"
-- (or inbound/outbound etc)
create table "idz_profile" (
"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" integer not null,
"exp" integer not null,
"fame" integer not null,
"dpoint" integer not null,
"mileage" integer not null,
"register_time" timestamp not null,
"access_time" timestamp not null,
constraint "idz_profile_player_uq" unique ("player_id")
);
create table "idz_chara" (
"id" integer primary key not null
references "idz_profile"("id")
on delete cascade,
"gender" text not null,
"field_02" integer not null,
"field_04" integer not null,
"field_06" integer not null,
"field_08" integer not null,
"field_0a" integer not null,
"field_0c" integer not null,
"field_0e" integer not null,
"title" integer not null,
"background" integer not null
);
create table "idz_course_plays" (
"id" integer primary key not null,
"profile_id" integer not null
references "idz_profile"("id")
on delete cascade,
"course_no" integer not null,
"count" integer not null,
constraint "idz_course_plays_uq" unique ("profile_id", "course_no")
);
create table "idz_car" (
"id" integer primary key not null,
"profile_id" integer not null
references "idz_profile"("id")
on delete cascade,
"selector" integer not null,
"field_00" integer not null,
"field_02" integer not null,
"field_04" text not null,
"field_46" integer not null,
"field_48" integer not null,
"field_4a" integer not null,
"field_4c" integer not null,
"field_50_lo" integer not null,
"field_50_hi" integer not null,
"field_58" integer not null,
"field_5a" integer not null,
"field_5b" integer not null,
"field_5c" integer not null,
"field_5e" integer not null,
constraint "idz_car_uq" unique ("profile_id", "selector")
);
create table "idz_car_selection" (
"id" integer primary key not null
references "idz_profile"("id")
on delete cascade,
"car_id" integer not null
references "idz_car"("id")
on delete cascade
);
create table "idz_solo_mission_state" (
"id" integer primary key not null,
"profile_id" integer not null
references "idz_profile"("id")
on delete cascade,
"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",
"cell_no"
)
);
create table "idz_settings" (
"id" integer primary key not null
references "idz_profile"("id")
on delete cascade,
"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" integer primary key not null
references "idz_profile"("id")
on delete cascade,
"x" integer not null,
"y" integer not null
);
create table "idz_story_cell_state" (
"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" integer not null,
"b" integer not null,
constraint "idz_story_cell_state_uq" unique (
"profile_id",
"row_no",
"col_no"
)
);
create table "idz_free_car" (
"id" integer primary key not null
references "idz_profile"("id")
on delete cascade,
"valid_from" timestamp not null
-- Expiry cannot be controlled by the server
);
-- Times are stored as floating-point seconds
create table "idz_ta_result" (
"id" integer primary key not null,
"profile_id" integer not null
references "idz_profile"("id")
on delete cascade,
"route_no" integer not null,
"total_time" float not null,
"section_times" text 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" integer primary key not null,
"profile_id" integer not null
references "idz_profile"("id")
on delete cascade,
"route_no" integer not null,
"total_time" float not null,
"section_times" text not null,
"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")
);
-- TODO ta_section_best
create table "idz_background_unlock" (
"id" integer primary key not null,
"profile_id" integer not null
references "idz_profile"("id")
on delete cascade,
"background_no" integer not null,
constraint "idz_background_unlock_uq" unique (
"profile_id",
"background_no"
)
);
create table "idz_title_unlock" (
"id" integer primary key not null,
"profile_id" integer not null
references "idz_profile"("id")
on delete cascade,
"title_no" integer not null,
constraint "idz_title_unlock_uq" unique ("profile_id", "title_no")
);
create table "idz_unlocks" (
"id" integer primary key not null
references "idz_profile"("id")
on delete cascade,
"cup" integer not null,
"gauges" integer not null,
"music" integer not null,
"last_mileage_reward" integer not null
);
create table "idz_team" (
"id" integer primary key not null,
"ext_id" integer not null,
"name" text 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" integer primary key not null
references "idz_team"("id")
on delete cascade,
"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" integer primary key not null
references "idz_profile"("id")
on delete cascade,
"team_id" integer not null
references "idz_team"("id")
on delete cascade,
"join_time" timestamp not null,
"leader" boolean not null
);
create table "idz_team_reservation" (
"id" integer primary key not null
references "aime_player"("id")
on delete cascade,
"team_id" integer not null
references "idz_team"("id")
on delete cascade,
"join_time" timestamp not null,
"leader" boolean not null
);