summaryrefslogtreecommitdiff
path: root/server/migrations/20221008120534_init.up.sql
diff options
context:
space:
mode:
authorKjetil Orbekk <kj@orbekk.com>2023-01-01 11:52:28 -0500
committerKjetil Orbekk <kj@orbekk.com>2023-01-01 11:52:28 -0500
commitbb2ed3a2926384df063e476d10613fa310cd7ffa (patch)
treecc9c6ea4979eef3850d78cd0b1390dfbccb5921b /server/migrations/20221008120534_init.up.sql
parent1e3014a777805d3dcb691ee6ebe59c62f58f8222 (diff)
Add Table to be used with db schema
Diffstat (limited to 'server/migrations/20221008120534_init.up.sql')
-rw-r--r--server/migrations/20221008120534_init.up.sql22
1 files changed, 19 insertions, 3 deletions
diff --git a/server/migrations/20221008120534_init.up.sql b/server/migrations/20221008120534_init.up.sql
index 05b7697..b8e8470 100644
--- a/server/migrations/20221008120534_init.up.sql
+++ b/server/migrations/20221008120534_init.up.sql
@@ -12,7 +12,7 @@ create table sessions (
last_refresh timestamp with time zone not null default now()
);
-create table active_tables (
+create table bridge_table (
id uuid primary key not null
);
@@ -29,9 +29,25 @@ create table object_journal (
create unique index journal_entry on object_journal (id, seq);
create table table_players (
- active_tables_id uuid not null references active_tables (id),
+ table_id uuid not null references bridge_table (id),
player_id varchar(64) not null references players (id),
position player_position,
- primary key(active_tables_id, player_id, position)
+ primary key(table_id, player_id, position)
);
create unique index player_table on table_players (player_id);
+
+create table table_boards (
+ table_id uuid not null references bridge_table (id),
+ board_number integer not null,
+ deal jsonb not null,
+ primary key(table_id, board_number)
+);
+
+create table table_moves (
+ table_id uuid not null,
+ board_number integer not null,
+ move_number integer not null,
+ move jsonb not null,
+ foreign key (table_id, board_number) references table_boards (table_id, board_number),
+ primary key(table_id, board_number, move_number)
+);