Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
yotta
/
pictogram
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
60
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
60f5c141
authored
Feb 17, 2017
by
Arturo Montejo Ráez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
student counter update removed from triggers-enrolments-integrity-constraints.sql
parent
47ce8243
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
58 deletions
sails/roles/database/files/triggers-enrolments-integrity-constraints.sql
sails/src/CHANGES.md
sails/roles/database/files/triggers-enrolments-integrity-constraints.sql
View file @
60f5c141
...
...
@@ -46,17 +46,11 @@ thisTrigger: BEGIN
AND
(
USER
()
=
'root@localhost'
)
THEN
LEAVE
thisTrigger
;
END
IF
;
UPDATE
office
SET
current_students
=
current_students
+
1
WHERE
office
.
id
=
new
.
id_off
;
END
IF
;
-- Load core collection for student
INSERT
INTO
stu_picto
(
id_stu
,
id_pic
,
attributes
)
SELECT
new
.
id
,
id_pic
,
concat
(
'{"id_cat":'
,
if
(
id_cat_pic
is
null
,
'null'
,
id_cat_pic
),
SELECT
new
.
id
,
id_pic
,
concat
(
'{"id_cat":'
,
if
(
id_cat_pic
is
null
,
'null'
,
id_cat_pic
),
',"coord_x":'
,
coord_x
,
',"coord_y":'
,
coord_y
,
',"status":"invisible"'
,
...
...
@@ -81,50 +75,12 @@ thisTrigger: BEGIN
IF
NOT
(
old
.
id_off
<=>
new
.
id_off
)
THEN
IF
(
old
.
id_off
IS
NOT
NULL
)
THEN
UPDATE
office
SET
current_students
=
current_students
-
1
WHERE
office
.
id
=
old
.
id_off
;
DELETE
stu_sup
FROM
stu_sup
INNER
JOIN
supervisor
ON
(
stu_sup
.
id_sup
=
supervisor
.
id
)
WHERE
id_stu
=
new
.
id
AND
old
.
id_off
=
supervisor
.
id_off
;
END
IF
;
IF
(
new
.
id_off
IS
NOT
NULL
)
THEN
UPDATE
office
SET
current_students
=
current_students
+
1
WHERE
office
.
id
=
new
.
id_off
;
END
IF
;
END
IF
;
END
;;
-- Integrity rule 4: office.current_enrolments when deleting student. Note that is not required to delete stu_sup because stu_sup.id_stu is a foreign key of student
DROP
TRIGGER
IF
EXISTS
TRG_DELETE_STUDENT_ENROLMENTS
;
CREATE
TRIGGER
TRG_DELETE_STUDENT_ENROLMENTS
AFTER
DELETE
ON
student
FOR
EACH
ROW
thisTrigger
:
BEGIN
IF
((
@
TRIGGER_CHECKS
=
FALSE
)
OR
(
@
TRIGGER_AFTER_DELETE_CHECKS
=
FALSE
))
AND
(
USER
()
=
'root@localhost'
)
THEN
LEAVE
thisTrigger
;
END
IF
;
IF
old
.
id_off
IS
NULL
THEN
UPDATE
office
SET
current_students
=
current_students
-
1
WHERE
office
.
id
=
old
.
id_off
;
END
IF
;
DELETE
stu_sup
FROM
stu_sup
INNER
JOIN
supervisor
ON
(
stu_sup
.
id_sup
=
supervisor
.
id
)
WHERE
id_stu
=
new
.
id
AND
old
.
id_off
=
supervisor
.
id_off
;
END
IF
;
END
IF
;
END
;;
DELIMITER
;
sails/src/CHANGES.md
View file @
60f5c141
...
...
@@ -13,11 +13,10 @@ Changes to be performed manually in servers to upgrade
## Database
-
load pictocat_tree_populate.sql
`source /vagrant/roles/database/files/pictocat_tree_populate.sql;`
(already done in dev)
-
load pictocat_tree_populate.sql
`source /vagrant/roles/database/files/pictocat_tree_populate.sql;`
-
reload trigers-enrolments-integrity-constraints.sql
-
alter table supervisor to add postal_code:
`alter table supervisor add column `
postal_code
` char(10) COLLATE utf8_unicode_ci NOT NULL;`
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment