Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit f77b2f9

Browse files
author
Jamie Snape
committed
Tweak database fields for consistency in length
1 parent ee363e3 commit f77b2f9

File tree

3 files changed

+66
-20
lines changed

3 files changed

+66
-20
lines changed

core/database/mysql/3.2.19.sql renamed to core/database/mysql/3.2.20.sql

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-- MIDAS Server. Copyright Kitware SAS. Licensed under the Apache License 2.0.
22

3-
-- MySQL core database, version 3.2.19
3+
-- MySQL core database, version 3.2.20
44

55
CREATE TABLE IF NOT EXISTS `activedownload` (
66
`activedownload_id` bigint(20) NOT NULL AUTO_INCREMENT,
@@ -108,7 +108,7 @@ CREATE TABLE IF NOT EXISTS `folder` (
108108
`description` text NOT NULL,
109109
`date_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
110110
`view` bigint(20) NOT NULL DEFAULT '0',
111-
`teaser` varchar(250) DEFAULT '',
111+
`teaser` varchar(255) DEFAULT '',
112112
`privacy_status` int(11) DEFAULT '0',
113113
`uuid` varchar(255) DEFAULT '',
114114
`date_creation` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -144,7 +144,7 @@ CREATE TABLE IF NOT EXISTS `group` (
144144

145145
CREATE TABLE IF NOT EXISTS `item` (
146146
`item_id` int(11) NOT NULL AUTO_INCREMENT,
147-
`name` varchar(250) NOT NULL,
147+
`name` varchar(255) NOT NULL,
148148
`date_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
149149
`description` text NOT NULL,
150150
`type` int(11) NOT NULL,
@@ -296,7 +296,7 @@ CREATE TABLE IF NOT EXISTS `setting` (
296296
CREATE TABLE IF NOT EXISTS `token` (
297297
`token_id` bigint(20) NOT NULL AUTO_INCREMENT,
298298
`userapi_id` bigint(20) NOT NULL,
299-
`token` varchar(40) NOT NULL,
299+
`token` varchar(64) NOT NULL,
300300
`expiration_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
301301
PRIMARY KEY (`token_id`)
302302
) DEFAULT CHARSET=utf8;
@@ -317,7 +317,7 @@ CREATE TABLE IF NOT EXISTS `user` (
317317
`city` varchar(100) DEFAULT '',
318318
`country` varchar(100) DEFAULT '',
319319
`website` varchar(255) DEFAULT '',
320-
`biography` varchar(255) DEFAULT '',
320+
`biography` text,
321321
`dynamichelp` tinyint(4) DEFAULT '1',
322322
`hash_alg` varchar(32) NOT NULL DEFAULT '',
323323
`salt` varchar(64) NOT NULL DEFAULT '',
@@ -334,8 +334,8 @@ CREATE TABLE IF NOT EXISTS `user2group` (
334334
CREATE TABLE IF NOT EXISTS `userapi` (
335335
`userapi_id` bigint(20) NOT NULL AUTO_INCREMENT,
336336
`user_id` bigint(20) NOT NULL,
337-
`apikey` varchar(40) NOT NULL,
338-
`application_name` varchar(256) NOT NULL,
337+
`apikey` varchar(64) NOT NULL,
338+
`application_name` varchar(255) NOT NULL,
339339
`token_expiration_time` int(11) NOT NULL,
340340
`creation_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
341341
PRIMARY KEY (`userapi_id`)

core/database/pgsql/3.2.19.sql renamed to core/database/pgsql/3.2.20.sql

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-- MIDAS Server. Copyright Kitware SAS. Licensed under the Apache License 2.0.
22

3-
-- PostgreSQL core database, version 3.2.19
3+
-- PostgreSQL core database, version 3.2.20
44

55
SET client_encoding = 'UTF8';
66
SET default_with_oids = FALSE;
@@ -104,7 +104,7 @@ CREATE TABLE IF NOT EXISTS "folder" (
104104
"description" text NOT NULL,
105105
"view" bigint DEFAULT 0::bigint NOT NULL,
106106
"date_update" timestamp without time zone NOT NULL DEFAULT now(),
107-
"teaser" character varying(250) DEFAULT ''::character varying,
107+
"teaser" character varying(256) DEFAULT ''::character varying,
108108
"privacy_status" integer DEFAULT 0 NOT NULL,
109109
"uuid" character varying(512) DEFAULT ''::character varying,
110110
"date_creation" timestamp without time zone
@@ -140,7 +140,7 @@ CREATE TABLE IF NOT EXISTS "group" (
140140

141141
CREATE TABLE IF NOT EXISTS "item" (
142142
"item_id" serial PRIMARY KEY,
143-
"name" character varying(250) NOT NULL,
143+
"name" character varying(256) NOT NULL,
144144
"date_update" timestamp without time zone NOT NULL DEFAULT now(),
145145
"description" text NOT NULL,
146146
"type" integer NOT NULL,
@@ -240,8 +240,8 @@ CREATE TABLE IF NOT EXISTS "metadatavalue" (
240240

241241
CREATE TABLE IF NOT EXISTS "newuserinvitation" (
242242
"newuserinvitation_id" serial PRIMARY KEY,
243-
"auth_key" character varying(255) NOT NULL,
244-
"email" character varying(255) NOT NULL,
243+
"auth_key" character varying(256) NOT NULL,
244+
"email" character varying(256) NOT NULL,
245245
"inviter_id" bigint NOT NULL,
246246
"community_id" bigint NOT NULL,
247247
"group_id" bigint NOT NULL,
@@ -257,10 +257,10 @@ ALTER TABLE "password" CLUSTER ON "password_hash";
257257

258258
CREATE TABLE IF NOT EXISTS "pendinguser" (
259259
"pendinguser_id" serial PRIMARY KEY,
260-
"auth_key" character varying(255) NOT NULL,
261-
"email" character varying(255) NOT NULL,
262-
"firstname" character varying(255) NOT NULL,
263-
"lastname" character varying(255) NOT NULL,
260+
"auth_key" character varying(256) NOT NULL,
261+
"email" character varying(256) NOT NULL,
262+
"firstname" character varying(256) NOT NULL,
263+
"lastname" character varying(256) NOT NULL,
264264
"date_creation" timestamp without time zone NOT NULL DEFAULT now(),
265265
"salt" character varying(64) DEFAULT ''::character varying NOT NULL
266266
);
@@ -284,7 +284,7 @@ CREATE TABLE IF NOT EXISTS "setting" (
284284
CREATE TABLE IF NOT EXISTS "token" (
285285
"token_id" serial PRIMARY KEY,
286286
"userapi_id" bigint NOT NULL,
287-
"token" character varying(40) NOT NULL,
287+
"token" character varying(64) NOT NULL,
288288
"expiration_date" timestamp without time zone NOT NULL DEFAULT now()
289289
);
290290

@@ -303,8 +303,8 @@ CREATE TABLE IF NOT EXISTS "user" (
303303
"uuid" character varying(512) DEFAULT ''::character varying,
304304
"city" character varying(100) DEFAULT ''::character varying,
305305
"country" character varying(100) DEFAULT ''::character varying,
306-
"website" character varying(255) DEFAULT ''::character varying,
307-
"biography" character varying(255) DEFAULT ''::character varying,
306+
"website" character varying(256) DEFAULT ''::character varying,
307+
"biography" text,
308308
"dynamichelp" integer DEFAULT 1,
309309
"hash_alg" character varying(32) DEFAULT ''::character varying NOT NULL,
310310
"salt" character varying(64) DEFAULT ''::character varying NOT NULL
@@ -319,7 +319,7 @@ CREATE TABLE IF NOT EXISTS "user2group" (
319319
CREATE TABLE IF NOT EXISTS "userapi" (
320320
"userapi_id" serial PRIMARY KEY,
321321
"user_id" bigint NOT NULL,
322-
"apikey" character varying(40) NOT NULL,
322+
"apikey" character varying(64) NOT NULL,
323323
"application_name" character varying(256) NOT NULL,
324324
"token_expiration_time" integer NOT NULL,
325325
"creation_date" timestamp without time zone

core/database/upgrade/3.2.20.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
/*=========================================================================
3+
MIDAS Server
4+
Copyright (c) Kitware SAS. 26 rue Louis Guérin. 69100 Villeurbanne, FRANCE
5+
All rights reserved.
6+
More information http://www.kitware.com
7+
8+
Licensed under the Apache License, Version 2.0 (the "License");
9+
you may not use this file except in compliance with the License.
10+
You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0.txt
13+
14+
Unless required by applicable law or agreed to in writing, software
15+
distributed under the License is distributed on an "AS IS" BASIS,
16+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
See the License for the specific language governing permissions and
18+
limitations under the License.
19+
=========================================================================*/
20+
21+
/** Upgrade the core to version 3.2.20. */
22+
class Upgrade_3_2_20 extends MIDASUpgrade
23+
{
24+
/** Upgrade a MySQL database. */
25+
public function mysql()
26+
{
27+
$this->db->query("ALTER TABLE `folder` CHANGE `teaser` `teaser` varchar(255) NULL DEFAULT '';");
28+
$this->db->query("ALTER TABLE `item` CHANGE `name` `name` varchar(255) NOT NULL;");
29+
$this->db->query("ALTER TABLE `token` CHANGE `token` `token` varchar(64) NOT NULL;");
30+
$this->db->query("ALTER TABLE `user` CHANGE COLUMN `biography` `biography` TEXT;");
31+
$this->db->query("ALTER TABLE `userapi` CHANGE `apikey` `apikey` varchar(64) NOT NULL, CHANGE `application_name` `application_name` varchar(255) NOT NULL;");
32+
}
33+
34+
/** Upgrade a PostgreSQL database. */
35+
public function pgsql()
36+
{
37+
$this->db->query("ALTER TABLE folder ALTER teaser TYPE character varying(256);");
38+
$this->db->query("ALTER TABLE item ALTER name TYPE character varying(256);");
39+
$this->db->query("ALTER TABLE token ALTER token TYPE character varying(64);");
40+
$this->db->query("ALTER TABLE newuserinvitation ALTER auth_key TYPE character varying(256), ALTER email TYPE character varying(256);");
41+
$this->db->query("ALTER TABLE pendinguser ALTER auth_key TYPE character varying(256), ALTER email TYPE character varying(256), ALTER firstname TYPE character varying(256), ALTER lastname TYPE character varying(256);");
42+
$this->db->query("ALTER TABLE \"user\" ALTER website TYPE character varying(256), ALTER biography TYPE text, ALTER biography DROP DEFAULT;");
43+
$this->db->query("ALTER TABLE userapi ALTER apikey TYPE character varying(64);");
44+
}
45+
}
46+

0 commit comments

Comments
 (0)