mirror of
https://github.com/joomla-extensions/weblinks.git
synced 2025-01-13 16:12:57 +00:00
Move adding columns into the script. Fixes #40
This commit is contained in:
parent
9a3c345e05
commit
c23179f1c7
@ -1,5 +1,3 @@
|
||||
# This is a rollup of all database schema changes applied from 3.0.0 to 3.3.x
|
||||
|
||||
ALTER TABLE `#__weblinks` ENGINE=InnoDB;
|
||||
ALTER TABLE `#__weblinks` ADD COLUMN `version` int(10) unsigned NOT NULL DEFAULT '1';
|
||||
ALTER TABLE `#__weblinks` ADD COLUMN `images` text NOT NULL;
|
||||
ALTER TABLE `#__weblinks` ENGINE=InnoDB;
|
@ -84,6 +84,9 @@ class Com_WeblinksInstallerScript
|
||||
|
||||
if (strpos($dbName, 'mysql') !== false)
|
||||
{
|
||||
// Add Missing Table Colums if needed
|
||||
$this->addColumnsIfNeeded();
|
||||
|
||||
// Drop the Table Colums if needed
|
||||
$this->dropColumnsIfNeeded();
|
||||
}
|
||||
@ -202,4 +205,31 @@ class Com_WeblinksInstallerScript
|
||||
$db->execute();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to add colums from #__weblinks if they are missing.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.4.1
|
||||
*/
|
||||
private function addColumnsIfNeeded()
|
||||
{
|
||||
$db = JFactory::getDbo();
|
||||
$table = $db->getTableColumns('#__weblinks');
|
||||
|
||||
if (!array_key_exists('version', $table))
|
||||
{
|
||||
$sql = 'ALTER TABLE ' . $db->quoteName('#__weblinks') . ' ADD COLUMN ' . $db->quoteName('version') . " int(10) unsigned NOT NULL DEFAULT '1'";
|
||||
$db->setQuery($sql);
|
||||
$db->execute();
|
||||
}
|
||||
|
||||
if (!array_key_exists('images', $table))
|
||||
{
|
||||
$sql = 'ALTER TABLE ' . $db->quoteName('#__weblinks') . ' ADD COLUMN ' . $db->quoteName('images') . ' text NOT NULL';
|
||||
$db->setQuery($sql);
|
||||
$db->execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user