From: Benjamin Auder Date: Thu, 27 Dec 2018 12:55:57 +0000 (+0100) Subject: Fix db scripts X-Git-Url: https://git.auder.net/doc/html/css/scripts/common.css?a=commitdiff_plain;h=c326e657d451c90220edbaa6f09fcb991350524c;p=vchess.git Fix db scripts --- diff --git a/README.md b/README.md index 2178d172..ef7cbb23 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,6 @@ Sounds and pieces images where found at various locations. 0. Install git-fat https://github.com/jedbrown/git-fat 1. git fat init && git fat pull - 2. Execute db/create.sql script (SQLite) to fill db/vchess.sqlite database - 3. Rename public/javascripts/socket\_url.js.dist into socket\_url.js - and adjust its content. + 2. Execute db/\*.sql scripts to create and fill db/vchess.sqlite + 3. Rename and edit public/javascripts/socket\_url.js.dist into socket\_url.js 4. npm i && npm start diff --git a/db/create.sql b/db/create.sql index 321274d0..c28bd561 100644 --- a/db/create.sql +++ b/db/create.sql @@ -1,28 +1,9 @@ --- database should be in this folder, and named 'vchess.sqlite' +-- Database should be in this folder, and named 'vchess.sqlite' create table Variants ( name varchar primary key, description text ); -insert into Variants values - ('Checkered', 'Shared pieces'), - ('Zen', 'Reverse captures'), - ('Atomic', 'Explosive captures'), - ('Chess960', 'Standard rules'), - ('Antiking', 'Keep antiking in check'), - ('Magnetic', 'Laws of attraction'), - ('Alice', 'Both sides of the mirror'), - ('Grand', 'Big board'), - ('Wildebeest', 'Balanced sliders & leapers'), - ('Loser', 'Lose all pieces'), - ('Crazyhouse', 'Captures reborn'), - ('Switching', 'Exchange pieces positions'), - ('Extinction', 'Capture all of a kind'), - ('Marseille', 'Move twice'), - ('Upsidedown', 'Walking on the hands'), - ('Dark', 'In the shadow'), - ('Berolina', 'Pawns move diagonally'), - ('Ultima', 'Exotic captures'); create table Problems ( num integer primary key, @@ -33,4 +14,5 @@ create table Problems ( solution text, foreign key (variant) references Variants(name) ); ---PRAGMA foreign_keys = ON; + +PRAGMA foreign_keys = ON; diff --git a/db/populate.sql b/db/populate.sql new file mode 100644 index 00000000..c577a6c2 --- /dev/null +++ b/db/populate.sql @@ -0,0 +1,21 @@ +-- Re-run this script after variants are added + +insert or ignore into Variants values + ('Alice', 'Both sides of the mirror'), + ('Antiking', 'Keep antiking in check'), + ('Atomic', 'Explosive captures'), + ('Baroque', 'Exotic captures'), + ('Berolina', 'Pawns move diagonally'), + ('Checkered', 'Shared pieces'), + ('Chess960', 'Standard rules'), + ('Crazyhouse', 'Captures reborn'), + ('Dark', 'In the shadow'), + ('Extinction', 'Capture all of a kind'), + ('Grand', 'Big board'), + ('Losers', 'Lose all pieces'), + ('Magnetic', 'Laws of attraction'), + ('Marseille', 'Move twice'), + ('Switching', 'Exchange pieces positions'), + ('Upsidedown', 'Walking on the hands'), + ('Wildebeest', 'Balanced sliders & leapers'), + ('Zen', 'Reverse captures');