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

Commit

Permalink
Tweak database fields for consistency in length
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Snape committed Dec 12, 2014
1 parent ee363e3 commit f77b2f9
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- MIDAS Server. Copyright Kitware SAS. Licensed under the Apache License 2.0.

-- MySQL core database, version 3.2.19
-- MySQL core database, version 3.2.20

CREATE TABLE IF NOT EXISTS `activedownload` (
`activedownload_id` bigint(20) NOT NULL AUTO_INCREMENT,
Expand Down Expand Up @@ -108,7 +108,7 @@ CREATE TABLE IF NOT EXISTS `folder` (
`description` text NOT NULL,
`date_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`view` bigint(20) NOT NULL DEFAULT '0',
`teaser` varchar(250) DEFAULT '',
`teaser` varchar(255) DEFAULT '',
`privacy_status` int(11) DEFAULT '0',
`uuid` varchar(255) DEFAULT '',
`date_creation` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
Expand Down Expand Up @@ -144,7 +144,7 @@ CREATE TABLE IF NOT EXISTS `group` (

CREATE TABLE IF NOT EXISTS `item` (
`item_id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(250) NOT NULL,
`name` varchar(255) NOT NULL,
`date_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`description` text NOT NULL,
`type` int(11) NOT NULL,
Expand Down Expand Up @@ -296,7 +296,7 @@ CREATE TABLE IF NOT EXISTS `setting` (
CREATE TABLE IF NOT EXISTS `token` (
`token_id` bigint(20) NOT NULL AUTO_INCREMENT,
`userapi_id` bigint(20) NOT NULL,
`token` varchar(40) NOT NULL,
`token` varchar(64) NOT NULL,
`expiration_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`token_id`)
) DEFAULT CHARSET=utf8;
Expand All @@ -317,7 +317,7 @@ CREATE TABLE IF NOT EXISTS `user` (
`city` varchar(100) DEFAULT '',
`country` varchar(100) DEFAULT '',
`website` varchar(255) DEFAULT '',
`biography` varchar(255) DEFAULT '',
`biography` text,
`dynamichelp` tinyint(4) DEFAULT '1',
`hash_alg` varchar(32) NOT NULL DEFAULT '',
`salt` varchar(64) NOT NULL DEFAULT '',
Expand All @@ -334,8 +334,8 @@ CREATE TABLE IF NOT EXISTS `user2group` (
CREATE TABLE IF NOT EXISTS `userapi` (
`userapi_id` bigint(20) NOT NULL AUTO_INCREMENT,
`user_id` bigint(20) NOT NULL,
`apikey` varchar(40) NOT NULL,
`application_name` varchar(256) NOT NULL,
`apikey` varchar(64) NOT NULL,
`application_name` varchar(255) NOT NULL,
`token_expiration_time` int(11) NOT NULL,
`creation_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`userapi_id`)
Expand Down
26 changes: 13 additions & 13 deletions core/database/pgsql/3.2.19.sql → core/database/pgsql/3.2.20.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- MIDAS Server. Copyright Kitware SAS. Licensed under the Apache License 2.0.

-- PostgreSQL core database, version 3.2.19
-- PostgreSQL core database, version 3.2.20

SET client_encoding = 'UTF8';
SET default_with_oids = FALSE;
Expand Down Expand Up @@ -104,7 +104,7 @@ CREATE TABLE IF NOT EXISTS "folder" (
"description" text NOT NULL,
"view" bigint DEFAULT 0::bigint NOT NULL,
"date_update" timestamp without time zone NOT NULL DEFAULT now(),
"teaser" character varying(250) DEFAULT ''::character varying,
"teaser" character varying(256) DEFAULT ''::character varying,
"privacy_status" integer DEFAULT 0 NOT NULL,
"uuid" character varying(512) DEFAULT ''::character varying,
"date_creation" timestamp without time zone
Expand Down Expand Up @@ -140,7 +140,7 @@ CREATE TABLE IF NOT EXISTS "group" (

CREATE TABLE IF NOT EXISTS "item" (
"item_id" serial PRIMARY KEY,
"name" character varying(250) NOT NULL,
"name" character varying(256) NOT NULL,
"date_update" timestamp without time zone NOT NULL DEFAULT now(),
"description" text NOT NULL,
"type" integer NOT NULL,
Expand Down Expand Up @@ -240,8 +240,8 @@ CREATE TABLE IF NOT EXISTS "metadatavalue" (

CREATE TABLE IF NOT EXISTS "newuserinvitation" (
"newuserinvitation_id" serial PRIMARY KEY,
"auth_key" character varying(255) NOT NULL,
"email" character varying(255) NOT NULL,
"auth_key" character varying(256) NOT NULL,
"email" character varying(256) NOT NULL,
"inviter_id" bigint NOT NULL,
"community_id" bigint NOT NULL,
"group_id" bigint NOT NULL,
Expand All @@ -257,10 +257,10 @@ ALTER TABLE "password" CLUSTER ON "password_hash";

CREATE TABLE IF NOT EXISTS "pendinguser" (
"pendinguser_id" serial PRIMARY KEY,
"auth_key" character varying(255) NOT NULL,
"email" character varying(255) NOT NULL,
"firstname" character varying(255) NOT NULL,
"lastname" character varying(255) NOT NULL,
"auth_key" character varying(256) NOT NULL,
"email" character varying(256) NOT NULL,
"firstname" character varying(256) NOT NULL,
"lastname" character varying(256) NOT NULL,
"date_creation" timestamp without time zone NOT NULL DEFAULT now(),
"salt" character varying(64) DEFAULT ''::character varying NOT NULL
);
Expand All @@ -284,7 +284,7 @@ CREATE TABLE IF NOT EXISTS "setting" (
CREATE TABLE IF NOT EXISTS "token" (
"token_id" serial PRIMARY KEY,
"userapi_id" bigint NOT NULL,
"token" character varying(40) NOT NULL,
"token" character varying(64) NOT NULL,
"expiration_date" timestamp without time zone NOT NULL DEFAULT now()
);

Expand All @@ -303,8 +303,8 @@ CREATE TABLE IF NOT EXISTS "user" (
"uuid" character varying(512) DEFAULT ''::character varying,
"city" character varying(100) DEFAULT ''::character varying,
"country" character varying(100) DEFAULT ''::character varying,
"website" character varying(255) DEFAULT ''::character varying,
"biography" character varying(255) DEFAULT ''::character varying,
"website" character varying(256) DEFAULT ''::character varying,
"biography" text,
"dynamichelp" integer DEFAULT 1,
"hash_alg" character varying(32) DEFAULT ''::character varying NOT NULL,
"salt" character varying(64) DEFAULT ''::character varying NOT NULL
Expand All @@ -319,7 +319,7 @@ CREATE TABLE IF NOT EXISTS "user2group" (
CREATE TABLE IF NOT EXISTS "userapi" (
"userapi_id" serial PRIMARY KEY,
"user_id" bigint NOT NULL,
"apikey" character varying(40) NOT NULL,
"apikey" character varying(64) NOT NULL,
"application_name" character varying(256) NOT NULL,
"token_expiration_time" integer NOT NULL,
"creation_date" timestamp without time zone
Expand Down
46 changes: 46 additions & 0 deletions core/database/upgrade/3.2.20.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
/*=========================================================================
MIDAS Server
Copyright (c) Kitware SAS. 26 rue Louis Guérin. 69100 Villeurbanne, FRANCE
All rights reserved.
More information http://www.kitware.com
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0.txt
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=========================================================================*/

/** Upgrade the core to version 3.2.20. */
class Upgrade_3_2_20 extends MIDASUpgrade
{
/** Upgrade a MySQL database. */
public function mysql()
{
$this->db->query("ALTER TABLE `folder` CHANGE `teaser` `teaser` varchar(255) NULL DEFAULT '';");
$this->db->query("ALTER TABLE `item` CHANGE `name` `name` varchar(255) NOT NULL;");
$this->db->query("ALTER TABLE `token` CHANGE `token` `token` varchar(64) NOT NULL;");
$this->db->query("ALTER TABLE `user` CHANGE COLUMN `biography` `biography` TEXT;");
$this->db->query("ALTER TABLE `userapi` CHANGE `apikey` `apikey` varchar(64) NOT NULL, CHANGE `application_name` `application_name` varchar(255) NOT NULL;");
}

/** Upgrade a PostgreSQL database. */
public function pgsql()
{
$this->db->query("ALTER TABLE folder ALTER teaser TYPE character varying(256);");
$this->db->query("ALTER TABLE item ALTER name TYPE character varying(256);");
$this->db->query("ALTER TABLE token ALTER token TYPE character varying(64);");
$this->db->query("ALTER TABLE newuserinvitation ALTER auth_key TYPE character varying(256), ALTER email TYPE character varying(256);");
$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);");
$this->db->query("ALTER TABLE \"user\" ALTER website TYPE character varying(256), ALTER biography TYPE text, ALTER biography DROP DEFAULT;");
$this->db->query("ALTER TABLE userapi ALTER apikey TYPE character varying(64);");
}
}

0 comments on commit f77b2f9

Please sign in to comment.