Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Add-ons that need adding DB columns or tables
How does one handle database table changes in an extension?
Suppose I need to add a column to the comments table for my extension to work. How would I do this? does it have to be done manually before installing the extension? if NOT, does it have to be removed afterwards?
I appreciate any explanation, to further my understanding of Vanilla ^^
0
This discussion has been closed.
Comments
//test if the extension is already installed if (!array_key_exists('YOUR_EXTENSION_VERSION', $Context->Configuration)) { //Part of the error message if the creation failed $senderObj = 'Your extension Installer'; $senderMethod = 'OpenConnection'; //don't know exactly what it is for //request //you can test the alter request in phpmyadmin first $AlterTable = "ALTER TABLE `". $DatabaseTables['TableName'] ."` ADD `ColumnName` INT( 11 )"; //The methode to execute the request $Context->Database->Execute($AlterTable , $senderObj, $senderMethod, 'Could not create ColumnName'); // If the column is created, add the extension version to settings.php // Next time the extension won't try to create the column if ($Context->ErrorManager->Iif()) { AddConfigurationSetting($Context, 'YOUR_EXTENSION_VERSION', '1.0'); } else { $Context->WarningCollector->Add($Context->GetDefinition('YourExtensionErrInstallation')); } } //Map to this new Column, usefull if you want to use the sqlbuider class in your extension. $Context->DatabaseColumns['TableName']['ColumnName'] = 'ColumnName';
I don't know for the Meta-extension.