mirror of
https://github.com/joomla-extensions/weblinks.git
synced 2024-06-03 06:50:49 +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
|
# 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` ENGINE=InnoDB;
|
||||||
ALTER TABLE `#__weblinks` ADD COLUMN `version` int(10) unsigned NOT NULL DEFAULT '1';
|
|
||||||
ALTER TABLE `#__weblinks` ADD COLUMN `images` text NOT NULL;
|
|
|
@ -84,6 +84,9 @@ class Com_WeblinksInstallerScript
|
||||||
|
|
||||||
if (strpos($dbName, 'mysql') !== false)
|
if (strpos($dbName, 'mysql') !== false)
|
||||||
{
|
{
|
||||||
|
// Add Missing Table Colums if needed
|
||||||
|
$this->addColumnsIfNeeded();
|
||||||
|
|
||||||
// Drop the Table Colums if needed
|
// Drop the Table Colums if needed
|
||||||
$this->dropColumnsIfNeeded();
|
$this->dropColumnsIfNeeded();
|
||||||
}
|
}
|
||||||
|
@ -202,4 +205,31 @@ class Com_WeblinksInstallerScript
|
||||||
$db->execute();
|
$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