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
35915b91
authored
Aug 11, 2017
by
Arturo Montejo Ráez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
upgrade.sql updated
parent
82659b8b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
11 deletions
sails/roles/database/files/upgrade.sql
sails/roles/database/files/upgrade.sql
View file @
35915b91
...
...
@@ -47,6 +47,21 @@ UPDATE license
SET
`type`
=
'official'
WHERE
`type`
<>
'trial'
;
ALTER
TABLE
supervisor
DROP
FOREIGN
KEY
supervisor_ibfk_1
;
ALTER
TABLE
supervisor
DROP
KEY
id_off
;
ALTER
TABLE
student
DROP
FOREIGN
KEY
student_ibfk_1
;
ALTER
TABLE
student
DROP
KEY
id_off
;
ALTER
TABLE
stu_sup
DROP
FOREIGN
KEY
stu_sup_ibfk_1
;
ALTER
TABLE
stu_sup
DROP
FOREIGN
KEY
stu_sup_ibfk_2
;
DELIMITER
$$
DROP
PROCEDURE
IF
EXISTS
supervisor_adapt
$$
CREATE
PROCEDURE
supervisor_adapt
()
...
...
@@ -57,13 +72,17 @@ BEGIN
DECLARE
id_off_actual
INT
;
DECLARE
name_sup
VARCHAR
(
80
);
DECLARE
off
ice
CURSOR
FOR
SELECT
id
,
name
,
admin
FROM
pictodb
.
office
;
DECLARE
off
_cur
CURSOR
FOR
SELECT
id
,
name
,
admin
FROM
pictodb
.
office
;
DECLARE
CONTINUE
HANDLER
FOR
NOT
FOUND
SET
done
=
TRUE
;
OPEN
off
ice
;
OPEN
off
_cur
;
read_loop
:
LOOP
FETCH
office
INTO
id_off_actual
,
name_sup
,
id_admin
;
FETCH
off_cur
INTO
id_off_actual
,
name_sup
,
id_admin
;
SELECT
concat
(
id_off_actual
,
' '
,
name_sup
,
' '
,
id_admin
);
SELECT
*
from
stu_sup
where
id_sup
=
105
;
IF
done
THEN
LEAVE
read_loop
;
...
...
@@ -72,14 +91,20 @@ BEGIN
UPDATE
supervisor
SET
name
=
name_sup
,
surname
=
''
,
role
=
'office'
WHERE
id
=
id_admin
;
UPDATE
student
SET
id_off
=
id_admin
WHERE
id_off
=
id_off_actual
;
SELECT
*
from
stu_sup
where
id_sup
=
105
;
UPDATE
supervisor
SET
id_off
=
id_admin
WHERE
id_off
=
id_off_actual
;
SELECT
*
from
stu_sup
where
id_sup
=
105
;
UPDATE
student
SET
id_off
=
id_admin
WHERE
id_off
=
id_off_actual
;
SELECT
*
from
stu_sup
where
id_sup
=
105
;
END
LOOP
;
CLOSE
off
ice
;
CLOSE
off
_cur
;
END
$$
END
$$
DELIMITER
;
CALL
supervisor_adapt
();
...
...
@@ -92,10 +117,9 @@ INSERT INTO sup_off (id_sup, id_off)
SELECT
id
,
id_off
FROM
supervisor
;
ALTER
TABLE
student
DROP
FOREIGN
KEY
student_ibfk_1
;
ALTER
TABLE
student
DROP
COLUMN
id_off
;
ALTER
TABLE
supervisor
DROP
FOREIGN
KEY
supervisor_ibfk_1
;
ALTER
TABLE
supervisor
DROP
COLUMN
id_off
;
ALTER
TABLE
stu_sup
ADD
CONSTRAINT
`stu_sup_ibfk_1`
FOREIGN
KEY
(
`id_stu`
)
REFERENCES
`student`
(
`id`
);
ALTER
TABLE
stu_sup
ADD
CONSTRAINT
`stu_sup_ibfk_2`
FOREIGN
KEY
(
`id_sup`
)
REFERENCES
`supervisor`
(
`id`
);
DROP
TABLE
office
;
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