diff --git a/mariadb/rappaurio.sql b/mariadb/rappaurio.sql new file mode 100644 index 0000000..6372abb --- /dev/null +++ b/mariadb/rappaurio.sql @@ -0,0 +1,33 @@ +-- Créer la base de données +CREATE DATABASE rappaurio; + +-- Utiliser la base de données +USE rappaurio; + +-- Créer la table "User" +CREATE TABLE User ( + id_user INT AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(255) NOT NULL, + email VARCHAR(255) NOT NULL UNIQUE, + password VARCHAR(255) NOT NULL +); + +-- Créer la table "Search" +CREATE TABLE Search ( + id_search INT AUTO_INCREMENT PRIMARY KEY, + id_user INT, + article1 VARCHAR(255) NOT NULL, + article2 VARCHAR(255) NOT NULL, + date TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (id_user) REFERENCES User(id_user) +); + +-- Créer l'utilsateur "radar" +CREATE USER IF NOT EXISTS 'radar'@'%' IDENTIFIED BY '$MYSQL_USER_PASSWORD'; +SET PASSWORD FOR 'radar'@'%' = PASSWORD('$MYSQL_USER_PASSWORD'); + +-- Donne les droits à l'utilisateur "radar" pour la BDD "rappaurio" +GRANT ALL PRIVILEGES ON rappaurio.* TO 'radar'@'%'; + +-- Applique les modifications +FLUSH PRIVILEGES; \ No newline at end of file