minime/schema/init/aime.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

36 lines
1.0 KiB
SQL

create table "aime_shop" (
"id" integer primary key not null,
"ext_id" integer not null,
"name" text not null,
"region" text not null,
constraint "aime_shop_uq" unique ("ext_id")
);
create table "aime_machine" (
"id" integer primary key not null,
"shop_id" integer not null
references "aime_shop"("id"),
"pcb_id" text not null,
"keychip_id" text not null,
constraint "aime_machine_pcb_id_uq" unique ("pcb_id"),
constraint "aime_machine_keychip_id_uq" unique ("keychip_id")
);
create table "aime_player" (
"id" integer primary key not null,
"ext_id" integer not null,
"register_time" timestamp not null,
constraint "aime_player_uq" unique ("ext_id")
);
create table "aime_card" (
"id" integer primary key not null,
"player_id" integer not null
references "aime_player"("id")
on delete cascade,
"nfc_id" text not null,
"register_time" timestamp not null,
"access_time" timestamp not null,
constraint "aime_card_uq" unique ("nfc_id")
);