summaryrefslogtreecommitdiff
path: root/server/migrations/20221008120534_init.up.sql
blob: db9fd3c2db493ceb822b4863449eea07fd2b3fa9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
-- Add up migration script here
create table players (
  id                         varchar(64) primary key not null
);

create table sessions (
  id   	     	             uuid primary key not null,
  player_id                  varchar(64) references players (id) not null,
  access_token	             varchar(2048) not null,
  access_token_expiration    timestamp with time zone not null,
  refresh_token		     varchar(1024) not null,
  last_refresh		     timestamp with time zone not null default now()
);

create table active_tables (
  id			     uuid primary key not null
);

create table object_journal (
  id   	     			uuid not null,
  seq				bigint not null,
  payload			jsonb not null
);
create unique index journal_entry on object_journal (id, seq);

create type player_position as enum ('west', 'north', 'east', 'south');

create table table_players (
  active_tables_id	     uuid not null references active_tables (id),
  player_id                  varchar(64) not null references players (id),
  position		     player_position,
  primary key(active_tables_id, player_id, position)
);
create unique index player_table on table_players (player_id);