TG-104 : Modif structure BDD

This commit is contained in:
Clément ARNAUDEAU 2017-01-23 12:26:07 +01:00
parent 3ac6092187
commit 534af3f7bb
4 changed files with 19 additions and 22 deletions

View File

@ -1,6 +1,6 @@
# Script de creation de la structure de la base OLA (a executer en root) # Script de creation de la structure de la base OLA (a executer en root)
-- INSTALLER LA DERNIERE VERSION DE MARIADB -- INSTALLER LA DERNIERE VERSION DE MARIADB
-- LANCER CE SCRIPT AVEC LA COMMANDE : mysql -u root < ola_export.mysql -- LANCER CE SCRIPT AVEC LA COMMANDE : mysql -u root < OLA.mysql
# Create schemas and users # Create schemas and users
CREATE DATABASE IF NOT EXISTS OLA CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE DATABASE IF NOT EXISTS OLA CHARACTER SET utf8 COLLATE utf8_general_ci;
@ -73,22 +73,21 @@ CREATE TABLE IF NOT EXISTS LIVRET
CREATE TABLE IF NOT EXISTS PERIOD CREATE TABLE IF NOT EXISTS PERIOD
( (
livret_id BIGINT NOT NULL, id BIGINT NOT NULL AUTO_INCREMENT,
num INT NOT NULL, livret_id BIGINT NOT NULL,
`type` INT, `type` INT,
`start` DATE, `start` DATE,
`end` DATE, `end` DATE,
student_desc TEXT, student_desc TEXT,
etutor_desc TEXT, etutor_desc TEXT,
ressources_dir VARCHAR(512), ressources_dir VARCHAR(512),
PRIMARY KEY(livret_id, num) PRIMARY KEY (id)
) ENGINE = INNODB; ) ENGINE = INNODB;
CREATE TABLE IF NOT EXISTS HASHTABLE CREATE TABLE IF NOT EXISTS HASHTABLE
( (
token VARCHAR(255) NOT NULL, token VARCHAR(255) NOT NULL,
exipre DATE NOT NULL, exipre DATE NOT NULL,
livret BIGINT NOT NULL,
period INT NOT NULL, period INT NOT NULL,
PRIMARY KEY(token) PRIMARY KEY(token)
) ENGINE = INNODB; ) ENGINE = INNODB;
@ -130,17 +129,16 @@ ALTER TABLE LIVRET
ON DELETE CASCADE ON DELETE CASCADE
ON UPDATE CASCADE ON UPDATE CASCADE
; ;
ALTER TABLE HASHTABLE ALTER TABLE PERIOD
ADD FOREIGN KEY (livret) ADD FOREIGN KEY (livret_id)
REFERENCES PERIOD(livret_id) REFERENCES LIVRET (id)
ON DELETE CASCADE ON DELETE CASCADE
ON UPDATE CASCADE ON UPDATE CASCADE;
;
ALTER TABLE HASHTABLE ALTER TABLE HASHTABLE
ADD FOREIGN KEY (livret, period) ADD FOREIGN KEY (period)
REFERENCES PERIOD(livret_id, num) REFERENCES PERIOD (id)
ON DELETE CASCADE ON DELETE CASCADE
ON UPDATE CASCADE ON UPDATE CASCADE
; ;

View File

@ -47,7 +47,7 @@ Installez la dernière version de MariaDB.
Lancer le script : Lancer le script :
``` ```
mysql -u root < ola_export.mysql mysql -u root < OLA.mysql
``` ```

View File

@ -35,7 +35,7 @@ class Prod(Config):
class Debug(Config): class Debug(Config):
DEBUG = True DEBUG = True
SESSION_COOKIE_SECURE = False SESSION_COOKIE_SECURE = False
SQLALCHEMY_DATABASE_URI = 'mysql://ola:ola@localhost/OLA' SQLALCHEMY_DATABASE_URI = 'mysql://ola:XXX@localhost/OLA'
class Test(Config): class Test(Config):

View File

@ -1,13 +1,12 @@
import importlib import importlib
from datetime import timedelta from datetime import timedelta
from app.config import Config
from flask import Flask, session from flask import Flask, session
from flask_restful import Api from flask_restful import Api
from flask_sqlalchemy import SQLAlchemy from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import create_engine from sqlalchemy import create_engine
from sqlalchemy.ext.automap import automap_base from sqlalchemy.ext.automap import automap_base
from app.config import Config
# initialization Flask # initialization Flask
app = Flask(__name__) app = Flask(__name__)