- Moved api files to a relevant subfolder
This commit is contained in:
176
api/database/auracle_db_create.sql
Normal file
176
api/database/auracle_db_create.sql
Normal file
@@ -0,0 +1,176 @@
|
||||
DROP DATABASE IF EXISTS auracle;
|
||||
CREATE DATABASE auracle CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||
USE auracle;
|
||||
|
||||
/* =========== PRIMARY TABLES =========== */
|
||||
|
||||
/* PERMISSIONS */
|
||||
CREATE TABLE IF NOT EXISTS `role` (
|
||||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`description` VARCHAR(255) NOT NULL,
|
||||
PRIMARY KEY(`id`)
|
||||
);
|
||||
|
||||
/* USERS */
|
||||
CREATE TABLE IF NOT EXISTS `user` (
|
||||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`uuid` VARCHAR(36) NOT NULL,
|
||||
`name` VARCHAR(255) NOT NULL DEFAULT "Disciple",
|
||||
`mail` VARCHAR(255) NOT NULL,
|
||||
`avatar` VARCHAR(255),
|
||||
`gender` VARCHAR(255),
|
||||
`password` VARCHAR(255) NOT NULL,
|
||||
`role_id` INT UNSIGNED NOT NULL DEFAULT 1,
|
||||
`verified` BOOLEAN DEFAULT false,
|
||||
`banned` BOOLEAN DEFAULT false,
|
||||
PRIMARY KEY(`id`),
|
||||
FOREIGN KEY(`role_id`) REFERENCES role(`id`)
|
||||
);
|
||||
|
||||
/* SPELLS */
|
||||
CREATE TABLE IF NOT EXISTS `spell` (
|
||||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(255) NOT NULL DEFAULT "Nom du sort",
|
||||
`description` VARCHAR(1000) NOT NULL DEFAULT "Description du sort",
|
||||
`level` INT UNSIGNED DEFAULT 0,
|
||||
`charge` INT UNSIGNED DEFAULT 0,
|
||||
`cost` VARCHAR(255) DEFAULT "0",
|
||||
`is_ritual` BOOLEAN DEFAULT false,
|
||||
`published` BOOLEAN DEFAULT true,
|
||||
`public` BOOLEAN DEFAULT true,
|
||||
`author_id` INT UNSIGNED NOT NULL DEFAULT 1,
|
||||
PRIMARY KEY (`id`),
|
||||
FOREIGN KEY(`author_id`) REFERENCES user(`id`)
|
||||
);
|
||||
|
||||
/* META SCHOOLS */
|
||||
CREATE TABLE IF NOT EXISTS `meta_school` (
|
||||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(255) NOT NULL DEFAULT "Nom de l'école mère",
|
||||
`description` VARCHAR(255) DEFAULT "Description de l'école mère",
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
|
||||
/* SCHOOLS */
|
||||
CREATE TABLE IF NOT EXISTS `school` (
|
||||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(255) NOT NULL DEFAULT "Nom de l'école",
|
||||
`description` VARCHAR(255) DEFAULT "Description de l'école",
|
||||
`meta_school_id` INT UNSIGNED NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
FOREIGN KEY(`meta_school_id`) REFERENCES meta_school(`id`)
|
||||
);
|
||||
|
||||
/* COMMON INGREDIENTS */
|
||||
CREATE TABLE IF NOT EXISTS `ingredient` (
|
||||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(255) NOT NULL DEFAULT "Langue de salamandre",
|
||||
`description` VARCHAR(255) NOT NULL DEFAULT "Une langue de salamandre de feu encore chaude.",
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
|
||||
/* COMMON VARIABLES */
|
||||
CREATE TABLE IF NOT EXISTS `variable` (
|
||||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`description` VARCHAR(255) NOT NULL DEFAULT "Nombre de créatures affectées",
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
|
||||
/* ==== ASSOCIATION TABLES ==== */
|
||||
|
||||
/* SPELLS' SCHOOLS */
|
||||
/* One spell can have multiple (up to 3) schools */
|
||||
CREATE TABLE IF NOT EXISTS `spell_school` (
|
||||
`spell_id` INT UNSIGNED NOT NULL,
|
||||
`school_id` INT UNSIGNED NOT NULL,
|
||||
PRIMARY KEY (`spell_id`, `school_id`),
|
||||
FOREIGN KEY(`spell_id`) REFERENCES spell(`id`),
|
||||
FOREIGN KEY(`school_id`) REFERENCES school(`id`)
|
||||
);
|
||||
|
||||
/* SPELLS' VARIABLES */
|
||||
/* One spell can have multiple (up to 2) variables of cost */
|
||||
CREATE TABLE IF NOT EXISTS `spell_variable` (
|
||||
`spell_id` INT UNSIGNED NOT NULL,
|
||||
`variable_id` INT UNSIGNED NOT NULL,
|
||||
PRIMARY KEY (`spell_id`, `variable_id`),
|
||||
FOREIGN KEY(`spell_id`) REFERENCES spell(`id`),
|
||||
FOREIGN KEY(`variable_id`) REFERENCES variable(`id`)
|
||||
);
|
||||
|
||||
/* SPELLS' VARIABLES */
|
||||
/* One spell can have multiple ingredients */
|
||||
CREATE TABLE IF NOT EXISTS `spell_ingredient` (
|
||||
`spell_id` INT UNSIGNED NOT NULL,
|
||||
`ingredient_id` INT UNSIGNED NOT NULL,
|
||||
PRIMARY KEY (`spell_id`, `ingredient_id`),
|
||||
FOREIGN KEY(`spell_id`) REFERENCES spell(`id`),
|
||||
FOREIGN KEY(`ingredient_id`) REFERENCES ingredient(`id`)
|
||||
);
|
||||
|
||||
/* Ajout d'une nouvelle ligne avant l'insert de description */
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `multiLine` BEFORE INSERT ON `spell` FOR EACH ROW
|
||||
BEGIN
|
||||
SET NEW.description = replace(NEW.description, '<l>', '\n');
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
||||
/* =========== PRIMARY INSERTS =========== */
|
||||
SET NAMES utf8;
|
||||
USE auracle;
|
||||
|
||||
-- PERMISSIONS
|
||||
INSERT INTO `role` (name, description) VALUES
|
||||
("Visiteur", "Utilisateur normal, peut consulter les sorts."),
|
||||
("Scribe", "Gardiens des écrits, les scribes sont capables de modifier et d'ajouter des sortilèges."),
|
||||
("Arcanologue", "Maîtres de l'arcane, ils ont le pouvoir et la responsabilité de juger les sortilèges récents et de les supprimer, ou valider."),
|
||||
("Augure", "Régents des grimoires, ils ont droit d'accès à l'intégralité des informations connues, et pouvoir absolu sur le savoir arcanique.");
|
||||
|
||||
-- META SCHOOLS
|
||||
INSERT INTO `meta_school` (name, description) VALUES
|
||||
('Magies blanches', 'Magies disciplinant les arts de soins et de lumières.'),
|
||||
('Magies noires', 'Magies disciplinant l\'art de la mort et des secrets.'),
|
||||
('Magies élémentaires', 'Magies disciplinant les éléments basiques tels que l\'eau, la foudre et le feu, pour n\'en citer que les plus populaires.'),
|
||||
('Magies spirituelles', 'Magies disciplinant l\'esprit, tant pour le défendre que l\'attaquer.'),
|
||||
('Magies spatio-temporelles', 'Magies régissant le temps et l\'espace.'),
|
||||
('Magies affiliées', 'Magies rattachées à une forme d\'énergie magique particulière.'),
|
||||
('Magies autres', 'Magies trop spécifiques et ne rentrant dans aucune autre grande école.');
|
||||
|
||||
-- SCHOOLS
|
||||
INSERT INTO `school` (name, description, meta_school_id) VALUES
|
||||
('Lumomancie', 'Discipline arcanique de la lumière.', 1),
|
||||
('Vitamancie', 'Discipline arcanique de la guérison et de l\'énergie vitale.', 1),
|
||||
('Obstrumancie', 'Discipline arcanique de la protection et des sceaux.', 1),
|
||||
('Tenebromancie', 'Discipline arcanique de la lumière.', 2),
|
||||
('Necromancie', 'Discipline arcanique de la mort.', 2),
|
||||
('Morbomancie', 'Discipline arcanique des maladies et malédictions.', 2),
|
||||
('Pyromancie', 'Discipline arcanique du feu.', 3),
|
||||
('Hydromancie', 'Discipline arcanique de l\'eau.', 3),
|
||||
('Electromancie', 'Discipline arcanique de la foudre.', 3),
|
||||
('Terramancie', 'Discipline arcanique de la terre.', 3),
|
||||
('Sidéromancie', 'Discipline arcanique des métaux rares et précieux.', 3),
|
||||
('Caelomancie', 'Discipline arcanique de l\'air.', 3),
|
||||
('Légimancie', 'Discipline arcanique de la lecture et du contrôle spirituel.', 4),
|
||||
('Illusiomancie', 'Discipline arcanique des illusions.', 4),
|
||||
('Cruciomancie', 'Discipline arcanique de la destruction spirituelle.', 4),
|
||||
('Chronomancie', 'Discipline arcanique du temps.', 5),
|
||||
('Spatiomancie', 'Discipline arcanique de l\'espace.', 5),
|
||||
('Kénomancie', 'Discipline arcanique du néant.', 6),
|
||||
('Lutomancie', 'Discipline arcanique des abysses.', 6),
|
||||
('Échomancie', 'Discipline arcanique de la résolution animique.', 6),
|
||||
('Protomancie', 'Discipline arcanique de la magie pure.', 7),
|
||||
('Rebumancie', 'Discipline arcanique de la lumière.', 7),
|
||||
('Vocamancie', 'Discipline arcanique de la lumière.', 7),
|
||||
('Somamancie', 'Discipline arcanique de la maîtrise corporelle.', 7),
|
||||
('Antimancie', 'Discipline arcanique de l\'annulation arcanique.', 7);
|
||||
|
||||
-- INGREDIENTS
|
||||
INSERT INTO `ingredient` (name, description) VALUES
|
||||
('Volonté', 'La force de volonté du lanceur, concentrée sur un objectif'),
|
||||
('Geste', 'Un geste précis facilitant la canalisation magique');
|
||||
|
||||
-- VARIABLES
|
||||
INSERT INTO `variable` (description) VALUES
|
||||
('Nombre de personnes soignées');
|
||||
37
api/database/auracle_db_schools.sql
Normal file
37
api/database/auracle_db_schools.sql
Normal file
@@ -0,0 +1,37 @@
|
||||
USE auracle;
|
||||
|
||||
/* Insertions de masses */
|
||||
DELIMITER $$
|
||||
CREATE PROCEDURE insertIntoSchoolRange(IN delimiter_start INT, IN delimiter_end INT, IN id_school INT)
|
||||
BEGIN
|
||||
SET @i = delimiter_start;
|
||||
WHILE @i <= delimiter_end DO
|
||||
INSERT INTO spell_school (spell_id, school_id) VALUES (@i, id_school);
|
||||
SET @i = @i + 1;
|
||||
END WHILE;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
||||
CALL insertIntoSchoolRange(1, 25, 1);
|
||||
CALL insertIntoSchoolRange(26, 50, 2);
|
||||
CALL insertIntoSchoolRange(51, 70, 3);
|
||||
CALL insertIntoSchoolRange(71, 95, 4);
|
||||
CALL insertIntoSchoolRange(96, 111, 5);
|
||||
CALL insertIntoSchoolRange(112, 115, 6);
|
||||
CALL insertIntoSchoolRange(116, 141, 7);
|
||||
CALL insertIntoSchoolRange(142, 167, 8);
|
||||
CALL insertIntoSchoolRange(168, 193, 9);
|
||||
CALL insertIntoSchoolRange(194, 217, 10);
|
||||
CALL insertIntoSchoolRange(218, 220, 11);
|
||||
CALL insertIntoSchoolRange(221, 242, 12);
|
||||
CALL insertIntoSchoolRange(243, 257, 13);
|
||||
CALL insertIntoSchoolRange(258, 272, 14);
|
||||
CALL insertIntoSchoolRange(273, 283, 15);
|
||||
CALL insertIntoSchoolRange(284, 301, 16);
|
||||
CALL insertIntoSchoolRange(302, 322, 17);
|
||||
CALL insertIntoSchoolRange(323, 339, 19);
|
||||
CALL insertIntoSchoolRange(340, 341, 20);
|
||||
CALL insertIntoSchoolRange(342, 356, 21);
|
||||
CALL insertIntoSchoolRange(357, 387, 22);
|
||||
CALL insertIntoSchoolRange(388, 396, 24);
|
||||
CALL insertIntoSchoolRange(397, 403, 25);
|
||||
18
api/database/bookshelf.js
Normal file
18
api/database/bookshelf.js
Normal file
@@ -0,0 +1,18 @@
|
||||
// MODULES
|
||||
const fs = require('fs')
|
||||
const mysql = require('mysql')
|
||||
|
||||
// Setting up the database connection
|
||||
const knex = require('knex')({
|
||||
client: "mysql",
|
||||
connection: {
|
||||
host : process.env.DB_HOST,
|
||||
user : process.env.DB_USER,
|
||||
password : process.env.DB_PASSWORD,
|
||||
database : "auracle",
|
||||
charset : "utf8"
|
||||
},
|
||||
})
|
||||
const bookshelf = require('bookshelf')(knex)
|
||||
|
||||
module.exports = { bookshelf }
|
||||
Reference in New Issue
Block a user