Update and push first changes
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 18 May 2018 20:56:15 +0000 (16:56 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 18 May 2018 20:56:15 +0000 (16:56 -0400)
still working on db

index.php
setup/databaseScripts/create_database_V0.0.1.sql [new file with mode: 0644]
setup/databaseScripts/dbVersions.php [new file with mode: 0644]
setup/databaseScripts/readme.txt [new file with mode: 0644]

index c71cb85..c31475e 100644 (file)
--- a/index.php
+++ b/index.php
@@ -150,14 +150,17 @@ if (is_file(GLM_MEMBERS_TRAVEL_PLUGIN_DB_SCRIPTS.'/dbVersions.php')) {
  *
  * Then add the data to the "config" array under "// Add this add-on to the add-ons array" below.
  */
+$glmMembersTravelDatabasePluginVersion = get_option('glmMembersDatabasePluginVersion');
 
-// Management
-// $glmMembersTravelManagementSettings = $wpdb->get_row( "SELECT * FROM ".GLM_MEMBERS_TRAVEL_PLUGIN_DB_PREFIX."management WHERE id = 1", ARRAY_A );
-// unset($glmMembersTravelManagementSettings['id']);
+if ( $glmMembersTravelDatabasePluginVersion ) {
+    // Management
+    $glmMembersTravelManagementSettings = $wpdb->get_row( "SELECT * FROM ".GLM_MEMBERS_TRAVEL_PLUGIN_DB_PREFIX."management WHERE id = 1", ARRAY_A );
+    unset($glmMembersTravelManagementSettings['id']);
 
-// Settings
-// $glmMembersTravelSettingsTerms = $wpdb->get_row( "SELECT * FROM ".GLM_MEMBERS_TRAVEL_PLUGIN_DB_PREFIX."settings_terms WHERE id = 1", ARRAY_A );
-// unset($glmMembersTravelSettingsTerms['id']);
+    // Settings
+    $glmMembersTravelSettingsTerms = $wpdb->get_row( "SELECT * FROM ".GLM_MEMBERS_TRAVEL_PLUGIN_DB_PREFIX."settings_terms WHERE id = 1", ARRAY_A );
+    unset($glmMembersTravelSettingsTerms['id']);
+}
 
 
 
@@ -171,8 +174,8 @@ function glmMembersTravelRegisterAddOn($addOns) {
         'slug' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG,
         'actions' => $GLOBALS['glmMembersTravelAddOnValidActions'],
         'config' => array(
-//            'settings' => $GLOBALS['glmMembersTravelManagementSettings'],
-//            'terms' => $GLOBALS['glmMembersTravelSettingsTerms']
+           'settings' => $GLOBALS['glmMembersTravelManagementSettings'],
+           'terms' => $GLOBALS['glmMembersTravelSettingsTerms']
         ),
         'shortcodes' => $GLOBALS['glmMembersTravelShortcodes'],
         'shortcodesDescription' => $GLOBALS['glmMembersTravelShortcodesDescription']
diff --git a/setup/databaseScripts/create_database_V0.0.1.sql b/setup/databaseScripts/create_database_V0.0.1.sql
new file mode 100644 (file)
index 0000000..1fc8b5a
--- /dev/null
@@ -0,0 +1,96 @@
+-- Gaslight Media Travel Leads Module
+-- File Created: 05/18/2018
+-- Database Version: 0.0.1
+-- Database Creation Script
+--
+-- To permit each query below to be executed separately,
+-- all queries must be separated by a line with four dashes
+--
+-- **** BE SURE TO ALSO UPDATE drop_database_Vxxx.sql FILE WHEN CHANGING TABLES ****
+--
+
+-- Leads
+CREATE TABLE {prefix}leads (
+    id INT NOT NULL AUTO_INCREMENT,
+    status INT NOT NULL DEFAULT 0,      -- Lead Status (active, inactive)
+    create_date DATE NOT NULL,          -- Date contact was created
+    fname TEXT NULL,                    -- First Name
+    lname TEXT NULL,                    -- Last Name
+    company TEXT NULL,                  -- Company Name
+    address TEXT NULL,                  -- Address
+    address2 TEXT NULL,                 -- Address 2
+    city TEXT NULL,                     -- City
+    state TEXT NULL,                    -- State
+    zip TEXT NULL,                      -- ZIP
+    phone TEXT NULL,                     -- Phone
+    fax TEXT NULL,                      -- Fax
+    mail_ok BOOLEAN DEFAULT false,      -- Mail OK (boolean)
+    website TEXT NULL,                  -- Website URL
+    PRIMARY KEY (id),
+    INDEX(create_date),
+    INDEX(email(20)),
+    INDEX(fname(20)),
+    INDEX(lname(20))
+);
+
+----
+
+-- ReferredBy Groups
+CREATE TABLE {prefix}referredby_groups (
+    id INT NOT NULL AUTO_INCREMENT,
+    name TEXT NOT NULL,                 -- Group Name
+    PRIMARY KEY (id)
+);
+
+----
+
+-- ReferredBy
+CREATE TABLE {prefix}referredby (
+    id INT NOT NULL AUTO_INCREMENT,
+    groupid INT NOT NULL,               -- Group Id
+    name TINYTEXT NOT NULL,             -- Name
+    pos INT NOT NULL DEFAULT 0,         -- Position number
+    PRIMARY KEY (id),
+    INDEX(groupid)
+);
+
+----
+
+-- Lead Notes
+CREATE TABLE {prefix}lead_notes
+    id INT NOT NULL AUTO_INCREMENT,
+    lead INT NOT NULL,                  -- Reference to lead table
+    created DATETIME NOT NULL,          -- Created Timestamp
+    notes TEXT,                         -- Note Entry
+    PRIMARY KEY (id),
+    INDEX(lead)
+);
+
+----
+
+-- Lead Contacts
+CREATE TABLE {prefix}lead_contacts (
+    id INT NOT NULL AUTO_INCREMENT,
+    lead INT NOT NULL,                  -- Reference to lead table
+    name TINYTEXT,                      -- Name of Contact
+    email TINYTEXT,                     -- Email of Contact
+    phone TINYTEXT,                     -- Phone of Contact
+    PRIMARY KEY (id),
+    INDEX(lead)
+);
+
+----
+
+-- Management
+CREATE TABLE {prefix}management (
+    id INT NOT NULL AUTO_INCREMENT,
+    PRIMARY KEY (id)
+);
+
+----
+
+-- settings_terms
+CREATE TABLE {prefix}settings_terms (
+    id INT NOT NULL AUTO_INCREMENT,
+    PRIMARY KEY (id)
+);
diff --git a/setup/databaseScripts/dbVersions.php b/setup/databaseScripts/dbVersions.php
new file mode 100644 (file)
index 0000000..f271145
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+/**
+ * Gaslight Media Members Database
+ * GLM Members Packaging DB Versions
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersTravelDatabase
+ * @author   Steve Sutton <steve@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @link     http://dev.gaslightmedia.com/
+ */
+
+/**
+ * Database Versions
+ *
+ * *** PLEASE NOW INCLUDE A DATE FOR EACH DATABASE VERSION ***
+ *  '1.1.2' => array('version' => '1.1.2', 'tables' => 14, 'date' => '4/11/16')
+ *
+ * An array of past and current Member Database versions.
+ *
+ * Each entry below uses a key so code can find data on
+ * a specific version and in the values are the version
+ * again and the proper number of tables that should
+ * exist with that version.
+ */
+$glmMembersDbVersions = array(
+    '0.0.1' => array('version' => '0.0.1', 'tables' => 5, 'date' => '05/18/18'),
+);
+
diff --git a/setup/databaseScripts/readme.txt b/setup/databaseScripts/readme.txt
new file mode 100644 (file)
index 0000000..047da61
--- /dev/null
@@ -0,0 +1,44 @@
+This directory contains database creation and update scripts for this add-on.
+
+The files in this directory are checked by the glmCheckDatabase() function in the
+main plugin classes/glmPluginSupport.php file.
+
+This directory is optional. If there are no data tables that need to be created
+for this add-on, there should be no files in this directory. The directory may
+also be deleted.
+
+See the "examples" directory for a sample of what can go in this directory.
+Procedure to update database
+-----------------------------
+
+0) Make a backup copy of the site's database.
+
+1) Rename "create_database_Vx.x.x.sql" to new version number.
+    example: create_database_V0.0.9.sql -> create_database_V0.0.10.sql
+
+2) Edit renamed create database file and make desired changes
+
+3) Add a new "update_database_Vx.x.x.sql" named with the correct version #.
+
+4) Edit new update database files with SQL script to make the necessary changes
+   from the previous version to the new version. (i.e. to add new fields,
+   rename fields, insert records, ...)
+
+5) Optionally add an "update_database_Vx.x.x.php" file if PHP scripting is
+   needed to update database content. (i.e. to make changes to database content)
+
+6) Edit the "dbVersions.php" file and add a new line for the new version.
+   *** Now please be sure to add a date for each entry ***
+   i.e. '1.1.2' => array('version' => '1.1.2', 'tables' => 14, 'date' => '4/11/16')
+
+7) When this is all done, edit the index.php file for the plugin/add-on and
+   change "GLM_MEMBERS_{addon}_PLUGIN_DB_VERSION" defined parameter where
+   {addon} is the add-on name.
+
+8) Go to an admin menu item for the main member db plugin or any add-on. If all
+   goes well, the main plugin should have detected the change and updated the
+   database. If not, restore the database and try again.
+
+9) Check the database to make sure the changes to fields and data are correct.
+
+10) Rename the drop_database_Vx.x.x.sql to new version number (same as create)