From c326e657d451c90220edbaa6f09fcb991350524c Mon Sep 17 00:00:00 2001
From: Benjamin Auder <benjamin.auder@somewhere>
Date: Thu, 27 Dec 2018 13:55:57 +0100
Subject: [PATCH] Fix db scripts

---
 README.md       |  5 ++---
 db/create.sql   | 24 +++---------------------
 db/populate.sql | 21 +++++++++++++++++++++
 3 files changed, 26 insertions(+), 24 deletions(-)
 create mode 100644 db/populate.sql

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');
-- 
2.44.0