From ac4688eac087854bf8cb0c893d7a79052ad63a20 Mon Sep 17 00:00:00 2001 From: redmatrix <git@macgirvin.com> Date: Fri, 27 May 2016 23:57:47 -0700 Subject: allow objs to represent inventory --- install/schema_mysql.sql | 2 ++ install/schema_postgres.sql | 2 ++ install/update.php | 19 ++++++++++++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) (limited to 'install') diff --git a/install/schema_mysql.sql b/install/schema_mysql.sql index 4751106da..a674ab8c4 100644 --- a/install/schema_mysql.sql +++ b/install/schema_mysql.sql @@ -883,6 +883,7 @@ CREATE TABLE IF NOT EXISTS `obj` ( `obj_imgurl` char(255) NOT NULL DEFAULT '', `obj_created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `obj_edited` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `obj_quantity` int(11) NOT NULL DEFAULT '0', `allow_cid` mediumtext NOT NULL, `allow_gid` mediumtext NOT NULL, `deny_cid` mediumtext NOT NULL, @@ -897,6 +898,7 @@ CREATE TABLE IF NOT EXISTS `obj` ( KEY `obj_imgurl` (`obj_imgurl`), KEY `obj_created` (`obj_created`), KEY `obj_edited` (`obj_edited`), + KEY `obj_quantity` (`obj_quantity`), KEY `obj_obj` (`obj_obj`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; diff --git a/install/schema_postgres.sql b/install/schema_postgres.sql index 75e53d3dd..e2c078dc1 100644 --- a/install/schema_postgres.sql +++ b/install/schema_postgres.sql @@ -873,6 +873,7 @@ CREATE TABLE "obj" ( "obj_imgurl" char(255) NOT NULL DEFAULT '', "obj_created" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00', "obj_edited" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00', + "obj_quantity" int(11) NOT NULL DEFAUL '0'. "allow_cid" text NOT NULL, "allow_gid" text NOT NULL, "deny_cid" text NOT NULL, @@ -890,6 +891,7 @@ create index "obj_url" on obj ("obj_url"); create index "obj_imgurl" on obj ("obj_imgurl"); create index "obj_created" on obj ("obj_created"); create index "obj_edited" on obj ("obj_edited"); +create index "obj_quantity" on obj ("obj_quantity"); CREATE TABLE "outq" ( "outq_hash" text NOT NULL, diff --git a/install/update.php b/install/update.php index ea1bd8bc7..983db1bb9 100644 --- a/install/update.php +++ b/install/update.php @@ -1,6 +1,6 @@ <?php -define( 'UPDATE_VERSION' , 1168 ); +define( 'UPDATE_VERSION' , 1169 ); /** * @@ -2097,3 +2097,20 @@ function update_r1167() { return UPDATE_SUCCESS; return UPDATE_FAILED; } + +function update_r1168() { + + $r1 = q("alter table obj add obj_quantity int not null default '0' "); + + if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { + $r2 = q("create index \"obj_quantity_idx\" on obj (\"obj_quantity\") "); + } + else { + $r2 = q("alter table obj add index ( obj_quantity ) "); + } + + if($r1 && $r2) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + -- cgit v1.2.3