From 9e931987e9ad1296414fbe5209c8fcc484dac2ee Mon Sep 17 00:00:00 2001 From: Kirk Webb Date: Tue, 11 Dec 2012 10:46:45 -0700 Subject: [PATCH] Add DB state for blockstore object composition. Also add state for tracking individual object attributes. --- sql/database-create.sql | 27 ++++++++++++++++++++++++++- sql/updates/4/335 | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 sql/updates/4/335 diff --git a/sql/database-create.sql b/sql/database-create.sql index 44471575b..5cb0479e4 100644 --- a/sql/database-create.sql +++ b/sql/database-create.sql @@ -134,6 +134,19 @@ CREATE TABLE `blobs` ( PRIMARY KEY (`uuid`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; +-- +-- Table structure for table `blockstore_attributes` +-- + +DROP TABLE IF EXISTS `blockstore_attributes`; +CREATE TABLE `blockstore_attributes` ( + `bsidx` int(10) unsigned NOT NULL, + `attrkey` varchar(32) NOT NULL default '', + `attrvalue` tinytext NOT NULL, + `attrtype` enum('integer','float','boolean','string') default 'string', + PRIMARY KEY (`bsidx`,`attrkey`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + -- -- Table structure for table `blockstore_state` -- @@ -149,6 +162,18 @@ CREATE TABLE `blockstore_state` ( UNIQUE KEY nidbid (`node_id`,`bs_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; +-- +-- Table structure for table `blockstore_trees` +-- + +DROP TABLE IF EXISTS `blockstore_trees`; +CREATE TABLE `blockstore_trees` ( + `bsidx` int(10) unsigned NOT NULL, + `aggidx` int(10) unsigned NOT NULL default '0', + `hint` tinytext NOT NULL, + PRIMARY KEY (`bsidx`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + -- -- Table structure for table `blockstore_type_attributes` -- @@ -172,7 +197,7 @@ CREATE TABLE `blockstores` ( `node_id` varchar(32) NOT NULL default '', `bs_id` varchar(32) NOT NULL default '', `type` varchar(30) NOT NULL default '', - `role` enum('infra','unused') NOT NULL default 'unused', + `role` enum('element','compound') NOT NULL default 'element', `total_size` int(10) unsigned NOT NULL default '0', `inception` datetime default NULL, PRIMARY KEY (`bsidx`), diff --git a/sql/updates/4/335 b/sql/updates/4/335 new file mode 100644 index 000000000..a7194a3a3 --- /dev/null +++ b/sql/updates/4/335 @@ -0,0 +1,41 @@ +# +# Add DB schema for tracking storage object composition and individual object +# attributes. +# + +use strict; +use libdb; + +sub DoUpdate($$$) +{ + my ($dbhandle, $dbname, $version) = @_; + + if (!DBTableExists("blockstore_trees")) { + DBQueryFatal("CREATE TABLE `blockstore_trees` (". + " `bsidx` int(10) unsigned NOT NULL,". + " `aggidx` int(10) unsigned NOT NULL default 0,". + " `hint` tinytext NOT NULL default '',". + " PRIMARY KEY (`bsidx`)". + ") ENGINE=MyISAM DEFAULT CHARSET=latin1"); + } + + if (!DBTableExists("blockstore_attributes")) { + DBQueryFatal("CREATE TABLE `blockstore_attributes` (". + " `bsidx` int(10) unsigned NOT NULL,". + " `attrkey` varchar(32) NOT NULL default '',". + " `attrvalue` tinytext NOT NULL,". + " `attrtype` enum('integer','float','boolean','string') default 'string',". + " PRIMARY KEY (`bsidx`,`attrkey`)". + ") ENGINE=MyISAM DEFAULT CHARSET=latin1"); + } + + + if (DBSlotExists("blockstores", "role")) { + DBQueryFatal("alter table blockstores change role role " . + " enum('element','compound') " . + " NOT NULL default 'element'"); + } + + return 0; +} +1; -- GitLab