source: admin/Database/ogAdmBD-1.1.1c-1.2.0.sql @ 4972d15

Last change on this file since 4972d15 was a0dd47a, checked in by Ramón M. Gómez <ramongomez@…>, 5 years ago

#992: Expand URL fields to support long hostnames.

Thanks to Jorge Fernandez Marín for the solution provided.

  • Property mode set to 100644
File size: 2.4 KB
Line 
1### Database update file.
2# OpenGnsys 1.1.1, 1.1.1a, 1.1.1b, 1.1.1c - OpenGnsys 1.2.0
3#use ogAdmBD
4
5DROP PROCEDURE IF EXISTS altercols;
6# Procedure to perform conditional table update.
7DELIMITER '//'
8CREATE PROCEDURE altercols() BEGIN
9        # Add row and column fields to locate computer in the lab (ticket #944).
10        IF NOT EXISTS (SELECT * FROM information_schema.COLUMNS
11                        WHERE COLUMN_NAME='n_row' AND TABLE_NAME='ordenadores' AND TABLE_SCHEMA=DATABASE())
12        THEN
13                ALTER TABLE ordenadores
14                        ADD n_row SMALLINT NOT NULL DEFAULT 0,
15                        ADD n_col SMALLINT NOT NULL DEFAULT 0;
16        END IF;
17        # Add maintenance and remote access fields for computers (tickets #991 y #992).
18        IF NOT EXISTS (SELECT * FROM information_schema.COLUMNS
19                        WHERE COLUMN_NAME='inremotepc' AND TABLE_NAME='ordenadores' AND TABLE_SCHEMA=DATABASE())
20        THEN
21                ALTER TABLE ordenadores
22                        ADD inremotepc SMALLINT NOT NULL DEFAULT 0,
23                        ADD maintenance SMALLINT NOT NULL DEFAULT 0;
24        END IF;
25        # Add URL to release a reserved computer for remote access (ticket #992).
26        IF NOT EXISTS (SELECT * FROM information_schema.COLUMNS
27                        WHERE COLUMN_NAME='urlrelease' AND TABLE_NAME='remotepc' AND TABLE_SCHEMA=DATABASE())
28        THEN
29                ALTER TABLE remotepc
30                        ADD urlrelease VARCHAR(255) DEFAULT NULL AFTER urllogout;
31        END IF;
32        # Add flag field to indicate if a local session is open (ticket #992).
33        IF NOT EXISTS (SELECT * FROM information_schema.COLUMNS
34                        WHERE COLUMN_NAME='islocal' AND TABLE_NAME='remotepc' AND TABLE_SCHEMA=DATABASE())
35        THEN
36                ALTER TABLE remotepc
37                        ADD islocal TINYINT NOT NULL DEFAULT 0;
38        END IF;
39        #
40        IF NOT EXISTS (SELECT * FROM information_schema.COLUMNS
41                        WHERE COLUMN_NAME='clonator' AND TABLE_NAME='imagenes' AND TABLE_SCHEMA=DATABASE())
42        THEN
43                ALTER TABLE imagenes
44                        ADD clonator varchar(100) NOT NULL DEFAULT '',
45                        ADD compressor varchar(100) NOT NULL DEFAULT '',
46                        ADD filesystem varchar(100) NOT NULL DEFAULT '',
47                        ADD datasize bigint NOT NULL DEFAULT 0;
48        END IF;
49END//
50# Run conditional update.
51DELIMITER ';'
52CALL altercols();
53DROP PROCEDURE altercols;
54
55# Redefine some fields as not null.
56ALTER TABLE aulas
57        MODIFY inremotepc SMALLINT NOT NULL DEFAULT 0;
58ALTER TABLE imagenes
59        MODIFY inremotepc SMALLINT NOT NULL DEFAULT 0;
60# Redefine some fields as null by default.
61ALTER TABLE remotepc
62      MODIFY urllogin VARCHAR(255) DEFAULT NULL,
63      MODIFY urllogout VARCHAR(255) DEFAULT NULL,
64      MODIFY urlrelease VARCHAR(255) DEFAULT NULL;
Note: See TracBrowser for help on using the repository browser.