From bb2ed3a2926384df063e476d10613fa310cd7ffa Mon Sep 17 00:00:00 2001
From: Kjetil Orbekk <kj@orbekk.com>
Date: Sun, 1 Jan 2023 11:52:28 -0500
Subject: Add Table to be used with db schema

---
 server/migrations/20221008120534_init.up.sql | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

(limited to 'server/migrations/20221008120534_init.up.sql')

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)
+);
-- 
cgit v1.2.3

