From 9ce3964b854b526af45081f67df82eca512ad9d0 Mon Sep 17 00:00:00 2001 From: Nicolas Paschoud <nicolas.paschoud@etu.hesge.ch> Date: Thu, 5 Dec 2019 10:31:43 +0100 Subject: [PATCH] Database is ready --- projet/data.sql | 35 ++++++++++++++++++++++++++++++++++ projet/docker-compose.yml | 17 +++++++++++++++++ projet/hyperdrive.sql | 40 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 projet/data.sql create mode 100644 projet/docker-compose.yml diff --git a/projet/data.sql b/projet/data.sql new file mode 100644 index 0000000..6e61410 --- /dev/null +++ b/projet/data.sql @@ -0,0 +1,35 @@ +USE hyperdrive; + +INSERT INTO Users +VALUES + ("a", "test"), + ("b", "test"), + ("c", "test"), + ("d", "test"), + ("e", "test"); + +INSERT INTO Paths +VALUES + ("/a", "a", NULL), + ("/a/coucou", "a", "/a"), + ("/b", "b", NULL), + ("/c", "c", NULL), + ("/c/test", "c", "/c"), + ("/d", "d", NULL), + ("/e", "e", NULL); + +INSERT INTO Files +VALUES + ("abcd", "un", "/a"), + ("ab", "deux", "/a"), + ("@dfsg", "trois", "/c/test"), + ("gbvaf", "quatre", "/b"), + ("dsfgh", "cinq", "/d"), + ("sdfa", "six", "/e"); + +INSERT INTO Shares +VALUES + ("a", "b", "abcd"), + ("a", "c", "abcd"), + ("a", "d", "abcd"), + ("c", "e", "@dfsg"); diff --git a/projet/docker-compose.yml b/projet/docker-compose.yml new file mode 100644 index 0000000..825f578 --- /dev/null +++ b/projet/docker-compose.yml @@ -0,0 +1,17 @@ +version: '3' +services: + db: + image: mysql + restart: always + container_name: hyperdrive + environment: + MYSQL_ROOT_PASSWORD: super + MYSQL_DATABASE: hyperdrive + MYSQL_USER: hyperdrive + MYSQL_PASSWORD: hyper + ports: + - '3306:3306' + expose: + - 3306 + volumes: + - ./hyperdrive.sql:/docker-entrypoint-initdb.d/hyperdrive.sql \ No newline at end of file diff --git a/projet/hyperdrive.sql b/projet/hyperdrive.sql index d7e5cc6..aa118fd 100644 --- a/projet/hyperdrive.sql +++ b/projet/hyperdrive.sql @@ -1,6 +1,8 @@ CREATE DATABASE IF NOT EXISTS `hyperdrive` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; USE `hyperdrive`; +-- Creating tables + CREATE TABLE IF NOT EXISTS Users ( pseudo varchar(60) NOT NULL, passwd varchar(256) NOT NULL, @@ -32,4 +34,40 @@ CREATE TABLE IF NOT EXISTS Shares ( FOREIGN KEY (pseudo_1) REFERENCES Users(pseudo), FOREIGN KEY (pseudo_2) REFERENCES Users(pseudo), FOREIGN KEY (file_id) REFERENCES Files(file_id) -); \ No newline at end of file +); + +-- Inserting datas + +INSERT INTO Users +VALUES + ("a", "test"), + ("b", "test"), + ("c", "test"), + ("d", "test"), + ("e", "test"); + +INSERT INTO Paths +VALUES + ("/a", "a", NULL), + ("/a/coucou", "a", "/a"), + ("/b", "b", NULL), + ("/c", "c", NULL), + ("/c/test", "c", "/c"), + ("/d", "d", NULL), + ("/e", "e", NULL); + +INSERT INTO Files +VALUES + ("abcd", "un", "/a"), + ("ab", "deux", "/a"), + ("@dfsg", "trois", "/c/test"), + ("gbvaf", "quatre", "/b"), + ("dsfgh", "cinq", "/d"), + ("sdfa", "six", "/e"); + +INSERT INTO Shares +VALUES + ("a", "b", "abcd"), + ("a", "c", "abcd"), + ("a", "d", "abcd"), + ("c", "e", "@dfsg"); -- GitLab