Commit 897c69d3 by Jose Antonio

Scene SQL - not finished

parent e6607142
...@@ -441,9 +441,9 @@ COMMENT="This table stores working session information. Every working session is ...@@ -441,9 +441,9 @@ COMMENT="This table stores working session information. Every working session is
CREATE TABLE IF NOT EXISTS `scene` ( CREATE TABLE IF NOT EXISTS `scene` (
`id` int(11) NOT NULL AUTO_INCREMENT, `id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`active` boolean NULL DEFAULT 0, `active` boolean NOT NULL DEFAULT 0,
`categories` boolean NULL DEFAULT 0, `categories` boolean NOT NULL DEFAULT 0,
`id_sup` int(11) NOT NULL, `id_sup` int(11) DEFAULT NULL,
`id_stu` int(11) NOT NULL, `id_stu` int(11) NOT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
FOREIGN KEY (`id_sup`) REFERENCES `supervisor` (`id`), FOREIGN KEY (`id_sup`) REFERENCES `supervisor` (`id`),
......
...@@ -13,6 +13,7 @@ CREATE PROCEDURE scene_adapt() ...@@ -13,6 +13,7 @@ CREATE PROCEDURE scene_adapt()
BEGIN BEGIN
DECLARE _id_stu INT; DECLARE _id_stu INT;
DECLARE _id_sup INT; DECLARE _id_sup INT;
DECLARE cat_active BOOLEAN;
DECLARE done INT DEFAULT FALSE; DECLARE done INT DEFAULT FALSE;
DECLARE LID INT; DECLARE LID INT;
...@@ -30,11 +31,14 @@ BEGIN ...@@ -30,11 +31,14 @@ BEGIN
LEAVE read_loop; LEAVE read_loop;
END IF; END IF;
SELECT `id_sup` INTO _id_sup FROM `stu_sup` WHERE `id_stu` = _id_stu LIMIT 1; SELECT attributes->"$.categories" INTO cat_active FROM student WHERE id = _id_stu;
SET cat_active = 0;
SELECT CONCAT('active: ', cat_active);
SELECT CONCAT('active: ', NOT cat_active);
/* FIRST SCENE, ACTIVE, WITH CATEGORIES */ /* FIRST SCENE, ACTIVE, WITH CATEGORIES */
INSERT INTO `scene` (name, active, categories, id_sup, id_stu) INSERT INTO `scene` (name, active, categories, id_stu)
VALUES ('with_categories', 1, 1, _id_sup, _id_stu); VALUES ('with_categories', cat_active, 1, _id_stu);
SET LID = LAST_INSERT_ID(); SET LID = LAST_INSERT_ID();
...@@ -46,7 +50,7 @@ BEGIN ...@@ -46,7 +50,7 @@ BEGIN
/* SECOND SCENE, NOT ACTIVE, NO CATEGORIES */ /* SECOND SCENE, NOT ACTIVE, NO CATEGORIES */
INSERT INTO `scene` (name, active, categories, id_sup, id_stu) INSERT INTO `scene` (name, active, categories, id_sup, id_stu)
VALUES ('no_categories', 0, 0, _id_sup, _id_stu); VALUES ('no_categories', NOT cat_active, 0, _id_sup, _id_stu);
SET LID = LAST_INSERT_ID(); SET LID = LAST_INSERT_ID();
......
...@@ -23,9 +23,9 @@ Changes to be performed manually in servers to upgrade ...@@ -23,9 +23,9 @@ Changes to be performed manually in servers to upgrade
`CREATE TABLE IF NOT EXISTS `scene` ( `CREATE TABLE IF NOT EXISTS `scene` (
`id` int(11) NOT NULL AUTO_INCREMENT, `id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`active` boolean NULL DEFAULT 0, `active` boolean NOT NULL DEFAULT 0,
`categories` boolean NULL DEFAULT 0, `categories` boolean NOT NULL DEFAULT 0,
`id_sup` int(11) NOT NULL, `id_sup` int(11) DEFAULT NULL,
`id_stu` int(11) NOT NULL, `id_stu` int(11) NOT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
FOREIGN KEY (`id_sup`) REFERENCES `supervisor` (`id`), FOREIGN KEY (`id_sup`) REFERENCES `supervisor` (`id`),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment