From a5079f205e8451b437d186098cd66a5a7bbe1b11 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 25 Aug 2017 15:35:17 -0400 Subject: [PATCH] add Manufacturers and Models Tables --- db/zm_create.sql.in | 25 ++++++++++++++++++++++++ db/zm_update-1.31.4.sql | 42 +++++++++++++++++++++++++++++++++++++++++ version | 2 +- 3 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 db/zm_update-1.31.4.sql diff --git a/db/zm_create.sql.in b/db/zm_create.sql.in index 0be21766b..659981407 100644 --- a/db/zm_create.sql.in +++ b/db/zm_create.sql.in @@ -286,6 +286,31 @@ CREATE TABLE `Logs` ( KEY `TimeKey` (`TimeKey`) ) ENGINE=@ZM_MYSQL_ENGINE@; +-- +-- Table structure for table `Manufacturers` +-- + +DROP TABLE IF EXISTS `Manufacturers`; +CREATE TABLE `Manufacturers` ( + `Id` int(10) unsigned NOT NULL auto_increment, + `Name` varchar(64) NOT NULL, + PRIMARY KEY (`Id`), + UNIQUE KEY (`Name`) +) ENGINE=@ZM_MYSQL_ENGINE@; + +-- +-- Table structure for table `Models` +-- + +DROP TABLE IF EXISTS `Models`; +CREATE TABLE `Models` ( + `Id` int(10) unsigned NOT NULL auto_increment, + `Name` varchar(64) NOT NULL, + `ManufacturerId` int(10), + PRIMARY KEY (`Id`), + UNIQUE KEY (`ManufacturerId`,`Name`) +) ENGINE=@ZM_MYSQL_ENGINE@; + -- -- Table structure for table `MonitorPresets` -- diff --git a/db/zm_update-1.31.4.sql b/db/zm_update-1.31.4.sql new file mode 100644 index 000000000..cebe2b4a3 --- /dev/null +++ b/db/zm_update-1.31.4.sql @@ -0,0 +1,42 @@ +-- +-- This adds Manufacturers and Models +-- + +SET @s = (SELECT IF( + (SELECT COUNT(*) + FROM INFORMATION_SCHEMA.TABLES + WHERE table_name = 'Manufacturers' + AND table_schema = DATABASE() + ) > 0, + "SELECT 'Manufacturers table exists'", + " + CREATE TABLE `Manufacturers` ( + `Id` int(10) unsigned NOT NULL auto_increment, + `Name` varchar(64) NOT NULL, + PRIMARY KEY (`Id`), + UNIQUE KEY (`Name`) + )" + )); + +PREPARE stmt FROM @s; +EXECUTE stmt; + +SET @s = (SELECT IF( + (SELECT COUNT(*) + FROM INFORMATION_SCHEMA.TABLES + WHERE table_name = 'Models' + AND table_schema = DATABASE() + ) > 0, + "SELECT 'Models table exists'", + "CREATE TABLE `Models` ( + `Id` int(10) unsigned NOT NULL auto_increment, + `Name` varchar(64) NOT NULL, + `ManufacturerId` int(10), + PRIMARY KEY (`Id`), + UNIQUE KEY (`ManufacturerId`,`Name`) + )" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; + diff --git a/version b/version index d7f92f588..cca52685e 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.31.3 +1.31.4