parent
6341ab2552
commit
9758a8ab73
@ -0,0 +1,168 @@ |
||||
SET statement_timeout = 0; |
||||
SET lock_timeout = 0; |
||||
SET idle_in_transaction_session_timeout = 0; |
||||
SET client_encoding = 'UTF8'; |
||||
SET standard_conforming_strings = on; |
||||
SELECT pg_catalog.set_config('search_path', '', false); |
||||
SET check_function_bodies = false; |
||||
SET xmloption = content; |
||||
SET client_min_messages = warning; |
||||
SET row_security = off; |
||||
|
||||
DROP DATABASE chessd; |
||||
|
||||
CREATE DATABASE chessd WITH TEMPLATE = template0 ENCODING = 'UTF8' LOCALE = 'en_US.UTF-8'; |
||||
|
||||
ALTER DATABASE chessd OWNER TO postgres; |
||||
|
||||
\connect chessd |
||||
|
||||
SET statement_timeout = 0; |
||||
SET lock_timeout = 0; |
||||
SET idle_in_transaction_session_timeout = 0; |
||||
SET client_encoding = 'UTF8'; |
||||
SET standard_conforming_strings = on; |
||||
SELECT pg_catalog.set_config('search_path', '', false); |
||||
SET check_function_bodies = false; |
||||
SET xmloption = content; |
||||
SET client_min_messages = warning; |
||||
SET row_security = off; |
||||
|
||||
SET default_tablespace = ''; |
||||
|
||||
SET default_table_access_method = heap; |
||||
|
||||
CREATE SEQUENCE public.seq_bid |
||||
START WITH 1 |
||||
INCREMENT BY 1 |
||||
NO MINVALUE |
||||
NO MAXVALUE |
||||
CACHE 1; |
||||
|
||||
ALTER TABLE public.seq_bid OWNER TO postgres; |
||||
|
||||
CREATE SEQUENCE public.seq_wid |
||||
START WITH 1 |
||||
INCREMENT BY 1 |
||||
NO MINVALUE |
||||
NO MAXVALUE |
||||
CACHE 1; |
||||
|
||||
ALTER TABLE public.seq_wid OWNER TO postgres; |
||||
|
||||
CREATE SEQUENCE public.context_seq_id |
||||
START WITH 1 |
||||
INCREMENT BY 1 |
||||
NO MINVALUE |
||||
NO MAXVALUE |
||||
CACHE 1; |
||||
|
||||
ALTER TABLE public.context_seq_id OWNER TO postgres; |
||||
|
||||
-- CREATE SEQUENCE public.seq_bw_id |
||||
-- START WITH 1 |
||||
-- INCREMENT BY 1 |
||||
-- NO MINVALUE |
||||
-- NO MAXVALUE |
||||
-- CACHE 1; |
||||
|
||||
-- ALTER TABLE public.seq_bw_id OWNER TO postgres; |
||||
|
||||
|
||||
-- CREATE TABLE public.match_input ( -- Solely accepts user input. |
||||
-- source text, |
||||
-- destination text |
||||
-- ); |
||||
|
||||
-- ALTER TABLE public.match_input OWNER TO postgres; |
||||
|
||||
-- CREATE TABLE public.match_output ( -- Movement output for AJAX. |
||||
-- status_msg text NOT NULL, |
||||
-- source text, |
||||
-- destination text |
||||
-- ); |
||||
|
||||
-- ALTER TABLE public.match_output OWNER TO postgres; |
||||
|
||||
CREATE TABLE public.context ( |
||||
id integer DEFAULT nextval('public.context_seq_id'::regclass), |
||||
bid integer, |
||||
wid integer, |
||||
bprio real, |
||||
wprio real |
||||
); |
||||
|
||||
ALTER TABLE public.context |
||||
ADD CONSTRAINT context_pkey PRIMARY KEY (id); |
||||
|
||||
ALTER TABLE public.context OWNER TO postgres; |
||||
|
||||
CREATE TABLE public.white ( -- Pieces of player 0. |
||||
id integer DEFAULT nextval('public.seq_wid'::regclass), |
||||
b0 numeric, |
||||
b1 numeric, |
||||
k0 numeric, |
||||
n0 numeric, |
||||
n1 numeric, |
||||
p0 numeric, |
||||
p1 numeric, |
||||
p2 numeric, |
||||
p3 numeric, |
||||
p4 numeric, |
||||
p5 numeric, |
||||
p6 numeric, |
||||
p7 numeric, |
||||
q0 numeric, |
||||
r0 numeric, |
||||
r1 numeric |
||||
); |
||||
|
||||
ALTER TABLE public.white |
||||
-- ADD CONSTRAINT white_pkey PRIMARY KEY (b0, b1, k0, n0, n1, p0, p1, p2, p3, p4, p5, p6, p7, q0, r0, r1); -- Error handling is bad. Avoid in favor of adding more checks. |
||||
ADD CONSTRAINT white_pkey PRIMARY KEY (id); |
||||
|
||||
ALTER TABLE public.white OWNER TO postgres; |
||||
|
||||
CREATE TABLE public.black ( -- Pieces of player 1. |
||||
id integer DEFAULT nextval('public.seq_bid'::regclass), |
||||
b0 numeric, |
||||
b1 numeric, |
||||
k0 numeric, |
||||
n0 numeric, |
||||
n1 numeric, |
||||
p0 numeric, |
||||
p1 numeric, |
||||
p2 numeric, |
||||
p3 numeric, |
||||
p4 numeric, |
||||
p5 numeric, |
||||
p6 numeric, |
||||
p7 numeric, |
||||
q0 numeric, |
||||
r0 numeric, |
||||
r1 numeric |
||||
); |
||||
|
||||
ALTER TABLE public.black |
||||
-- ADD CONSTRAINT black_pkey PRIMARY KEY (b0, b1, k0, n0, n1, p0, p1, p2, p3, p4, p5, p6, p7, q0, r0, r1); -- Error handling is bad. Avoid in favor of adding more checks. |
||||
ADD CONSTRAINT black_pkey PRIMARY KEY (id); |
||||
|
||||
ALTER TABLE public.black OWNER TO postgres; |
||||
|
||||
CREATE TABLE public.sessions ( |
||||
session text, |
||||
bid integer, |
||||
wid integer |
||||
); |
||||
|
||||
ALTER TABLE public.sessions |
||||
ADD CONSTRAINT sessions_pkey PRIMARY KEY (session); |
||||
|
||||
ALTER TABLE public.sessions OWNER TO postgres; |
||||
|
||||
CREATE INDEX bidx_context ON public.context USING btree (bid); |
||||
CREATE INDEX widx_context ON public.context USING btree (wid); |
||||
|
||||
ALTER TABLE ONLY public.context |
||||
ADD CONSTRAINT bid_fkey FOREIGN KEY (bid) REFERENCES public.black(id) ON UPDATE RESTRICT ON DELETE CASCADE, |
||||
ADD CONSTRAINT wid_fkey FOREIGN KEY (wid) REFERENCES public.white(id) ON UPDATE RESTRICT ON DELETE CASCADE; |
Loading…
Reference in new issue