function up() { echo "Starting Migration Proc ...<BR>"; //check if migration already had ran ... $migration = DataObject::get_one("Migration", "Name='{$this->title}'"); if (!$migration) { DB::getConn()->transactionStart(); try { // migrate records from Live to Stage table DB::query("DELETE FROM JobPage"); DB::query("\nINSERT INTO JobPage\n\t\t(ID,\n\t\tJobPostedDate,\n\t\tJobCompany,\n\t\tJobMoreInfoLink,\n\t\tJobLocation,\n\t\tFoundationJob,\n\t\tExpirationDate,\n\t\tActive,\n\t\tJobInstructions2Apply,\n\t\tLocationType,\n\t\tTitle,\n\t\tContent)\nSELECT \tJobPage_Live.ID,\n\t\tJobPostedDate,\n\t\tJobCompany,\n\t\tJobMoreInfoLink,\n\t\tJobLocation,\n\t\tFoundationJob,\n\t\tExpirationDate,\n\t\tActive,\n\t\tJobInstructions2Apply,\n\t\tLocationType,\n\t\tTitle,\n\t\tContent\nFROM \tJobPage_Live\nINNER JOIN Page_Live on Page_Live.Id = JobPage_Live.Id\nINNER JOIN SiteTree_Live on SiteTree_Live.Id = JobPage_Live.Id"); DB::query("DROP TABLE JobPage_Live"); DB::query("DROP TABLE JobPage_versions"); // delete orphan records DB::query("delete from Page where Id in (select Id from SiteTree where ClassName = 'JobPage')"); DB::query("delete from SiteTree where ClassName = 'JobPage'"); DB::query("delete from Page_Live where Id in (select Id from SiteTree_Live where ClassName = 'JobPage')"); DB::query("delete from SiteTree_Live where ClassName = 'JobPage'"); DB::query("delete from Page_versions where Id in (select Id from SiteTree_versions where ClassName = 'JobPage')"); DB::query("delete from SiteTree_versions where ClassName = 'JobPage'"); DB::getConn()->transactionEnd(); } catch (Exception $e) { DB::getConn()->transactionRollback(); return; } $migration = new Migration(); $migration->Name = $this->title; $migration->Description = $this->description; $migration->Write(); } echo "Ending Migration Proc ...<BR>"; }
function up() { echo "Starting Proc ...<BR>"; $migration = DataObject::get_one("Migration", "Name='{$this->title}'"); if (!$migration) { $migration = new Migration(); $migration->Name = $this->title; $migration->Description = $this->description; $migration->Write(); //run migration $sql = <<<SQL \t\tupdate DeploymentSurvey set InformationSources = REPLACE(InformationSources,'ask.openstack.org','Ask OpenStack (ask.openstack.org)') where InformationSources like '%ask.openstack.org%'; SQL; DB::query($sql); $sql = <<<SQL update Deployment set DeploymentStage = REPLACE(DeploymentStage,'Dev/QA','Under development/in testing') where DeploymentStage like '%Dev/QA%'; SQL; DB::query($sql); $sql = <<<SQL update Deployment set OtherWhyNovaNetwork = WhyNovaNetwork where WhyNovaNetwork is not null; SQL; DB::query($sql); $sql = <<<SQL update Deployment set WhyNovaNetwork = 'Other (please specify)' where OtherWhyNovaNetwork is not null; SQL; DB::query($sql); } else { echo "Migration Already Ran! <BR>"; } echo "Migration Done <BR>"; }
function up() { echo "Starting Migration Proc ...<BR>"; //check if migration already had ran ... $migration = Migration::get()->filter('Name', $this->title)->first(); if (!$migration) { $marketplace_types = array('Private Cloud'); $factory = new MarketplaceFactory(); $service = new MarketplaceTypeManager(new SapphireMarketPlaceTypeRepository(), new SapphireSecurityGroupRepository(), SapphireTransactionManager::getInstance()); foreach ($marketplace_types as $marketplace_type) { try { $service->store($factory->buildMarketplaceType($marketplace_type)); } catch (Exception $ex) { } } DB::query("INSERT INTO CloudServiceOffered_PricingSchemas (CloudServiceOfferedID, PricingSchemaTypeID) SELECT PublicCloudServiceOfferedID, PricingSchemaTypeID FROM PublicCloudServiceOffered_PricingSchemas;"); DB::query("UPDATE OpenStackImplementationApiCoverage SET ClassName='CloudServiceOffered'\nWHERE ImplementationID IN (SELECT ID FROM CompanyService where ClassName='PublicCloudService');"); DB::query("UPDATE DataCenterRegion SET CloudServiceID = PublicCloudID;"); DB::query("ALTER TABLE `CloudServiceOffered_PricingSchemas`\n\t\t\tADD UNIQUE INDEX `CloudServiceOffered_PricingSchemaType` (`CloudServiceOfferedID` ASC, `PricingSchemaTypeID` ASC);"); DB::query("ALTER TABLE `DataCenterRegion` DROP INDEX `Name_PublicCloud`;"); DB::query("ALTER TABLE `DataCenterRegion`\n\t\t\tADD UNIQUE INDEX `Name_CloudService` (`Name` ASC, `CloudServiceID` ASC);"); $migration = new Migration(); $migration->Name = $this->title; $migration->Description = $this->description; $migration->Write(); } echo "Ending Migration Proc ...<BR>"; }
function plugin_environment_install() { global $DB; include_once GLPI_ROOT . "/plugins/environment/inc/profile.class.php"; $update = false; if (TableExists("glpi_plugin_environment_profiles") && FieldExists("glpi_plugin_environment_profiles", "interface")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/environment/sql/update-1.3.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/environment/sql/update-1.4.0.sql"); } else { if (TableExists("glpi_plugin_environment_profiles") && FieldExists("glpi_plugin_environment_profiles", "connections")) { $update = true; $DB->runFile(GLPI_ROOT . "/plugins/environment/sql/update-1.4.0.sql"); } } if ($update) { //Do One time on 0.78 $query_ = "SELECT *\n FROM `glpi_plugin_environment_profiles` "; $result_ = $DB->query($query_); if ($DB->numrows($result_) > 0) { while ($data = $DB->fetch_array($result_)) { $query = "UPDATE `glpi_plugin_environment_profiles`\n SET `profiles_id` = '" . $data["id"] . "'\n WHERE `id` = '" . $data["id"] . "';"; $result = $DB->query($query); } } $query = "ALTER TABLE `glpi_plugin_environment_profiles`\n DROP `name` ;"; $result = $DB->query($query); } PluginEnvironmentProfile::initProfile(); PluginEnvironmentProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']); $migration = new Migration("1.8.0"); $migration->dropTable('glpi_plugin_environment_profiles'); $_SESSION["glpi_plugin_environment_installed"] = 1; return true; }
public function actionCreate() { $model = new Migration(); $form = new Form('codegen.MigrationForm', $model); if ($form->submitted() && $model->validate()) { $res = Yii::app()->db->createCommand("SHOW CREATE TABLE {$model->table}")->queryRow(); $sql = $res['Create Table']; $sql = explode("\n", $sql); foreach ($sql as $i => $str) { if ($i == 0) { continue; } $sql[$i] = str_repeat(' ', 14) . $str; } $sql = implode("\n", $sql); $dir = APP_PATH . DS . 'modules' . DS . $model->module . DS . 'migrations' . DS; if (!is_dir($dir)) { mkdir($dir, 0777); chmod($dir, 0777); } $name = 'm' . date('ymd') . '_' . date('His') . '_' . $model->table . '_create'; $file = $dir . $name . '.php'; $params = array('name' => $name, 'table' => $model->table, 'sql' => $sql); $code = $this->renderPartial('codegen.views.templates.migration', $params, true); file_put_contents($file, $code); chmod($file, 0777); Yii::app()->user->setFlash('success', t('Создана миграция') . ' ' . $name); } $this->render('create', array('form' => $form)); }
function up() { echo "Starting Migration Proc ...<BR>"; //check if migration already had ran ... $migration = Migration::get()->filter('Name', $this->title)->first(); if (!$migration) { $SQL = <<<SQL INSERT INTO `VideoPresentation` ( `ClassName`, `Created`, `LastEdited`, `Name`, `DisplayOnSite`, `Featured`, `City`, `Country`, `Description`, `YouTubeID`, `URLSegment`, `StartTime`, `EndTime`, `Location`, `Type`, `Day`, `Speakers`, `SlidesLink`, `event_key`, `IsKeynote`, `PresentationCategoryPageID`, `SummitID`, `MemberID`) SELECT 'VideoPresentation', NOW(),NOW(),Name, `DisplayOnSite`, `Featured`, `City`, `Country`, `Description`, `YouTubeID`, `URLSegment`, `StartTime`, `EndTime`, `Location`, `Type`, `Day`, `Speakers`, `SlidesLink`, `event_key`, `IsKeynote`, `PresentationCategoryPageID`, `SummitID`, `MemberID` FROM Presentation; SQL; DB::query($SQL); $migration = new Migration(); $migration->Name = $this->title; $migration->Description = $this->description; $migration->Write(); } echo "Ending Migration Proc ...<BR>"; }
function plugin_ticketmail_install() { global $DB; $migration = new Migration(100); //Fresh install if (!TableExists('glpi_plugin_ticketmail_profiles')) { $query = "CREATE TABLE `glpi_plugin_ticketmail_profiles` (\n\t\t\t\t\t`id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_profiles (id)',\n\t\t\t\t\t`show_ticketmail_onglet` char(1) collate utf8_unicode_ci default NULL,\n\t\t\t\t\tPRIMARY KEY (`id`)\n\t\t\t\t ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; $DB->queryOrDie($query, $DB->error()); $migration->executeMigration(); include_once GLPI_ROOT . "/plugins/ticketmail/inc/profile.class.php"; PluginTicketmailProfile::createAdminAccess($_SESSION['glpiactiveprofile']['id']); } else { // Since v0.84 remove "profiles_id" column and use "id" if (FieldExists('glpi_plugin_ticketmail_profiles', 'profiles_id')) { $drop_column_query = "ALTER TABLE glpi_plugin_ticketmail_profiles DROP COLUMN `id`;"; $rename_column_query = "ALTER TABLE glpi_plugin_ticketmail_profiles\n\t\t\t\t\t\t\t\t\tCHANGE profiles_id id int(11) NOT NULL default '0'\n\t\t\t\t\t\t\t\t\tCOMMENT 'RELATION to glpi_profiles (id)';"; $DB->queryOrDie($drop_column_query, $DB->error()); $DB->queryOrDie($rename_column_query, $DB->error()); $add_primarykey_query = "ALTER TABLE glpi_plugin_ticketmail_profiles\n\t\t\t\t\t\t\t\t\t ADD PRIMARY KEY (id);"; $drop_old_index_query = "ALTER TABLE glpi_plugin_ticketmail_profiles\n\t\t\t\t\t\t\t\t\t DROP INDEX profiles_id;"; $DB->queryOrDie($add_primarykey_query, $DB->error()); $DB->queryOrDie($drop_old_index_query, $DB->error()); } } return true; }
/** * Install or update dropdowns * * @param Migration $migration Migration instance * @param string $version Plugin current version * * @return void */ static function install(Migration $migration, $version) { $migration->displayMessage(__("Updating generated dropdown files", "fields")); // -> 0.90-1.3: generated class moved // OLD path: GLPI_ROOT."/plugins/fields/inc/$class_filename" // NEW path: PLUGINFIELDS_CLASS_PATH . "/$class_filename" // OLD path: GLPI_ROOT."/plugins/fields/front/$class_filename" // NEW path: PLUGINFIELDS_FRONT_PATH . "/$class_filename" $obj = new PluginFieldsField(); $fields = $obj->find('type = "dropdown"'); foreach ($fields as $field) { //First, drop old fields from plugin directories $class_filename = $field['name'] . "dropdown.class.php"; if (file_exists(GLPI_ROOT . "/plugins/fields/inc/{$class_filename}")) { unlink(GLPI_ROOT . "/plugins/fields/inc/{$class_filename}"); } $front_filename = $field['name'] . "dropdown.php"; if (file_exists(GLPI_ROOT . "/plugins/fields/front/{$front_filename}")) { unlink(GLPI_ROOT . "/plugins/fields/front/{$front_filename}"); } $form_filename = $field['name'] . "dropdown.form.php"; if (file_exists(GLPI_ROOT . "/plugins/fields/front/{$form_filename}")) { unlink(GLPI_ROOT . "/plugins/fields/front/{$form_filename}"); } //Second, create new files self::create($field); } return true; }
static function install(Migration $migration) { global $DB; // Table no longer needed in GLPI 0.85+; drop it. Needed for upgrades $migration->dropTable(getTableForItemType(__CLASS__)); PluginSimcardProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']); }
/** * Migrates the database to the version specified * * @param array $options Configuration to use */ protected function _execute(array $options) { $groups = $options['group']; $target = $options['to']; $dry_run = $options['dry-run'] !== FALSE; $quiet = $options['quiet'] !== FALSE; $up = $options['up'] !== FALSE; $down = $options['down'] !== FALSE; $groups = $this->_parse_groups($groups); if ($target === NULL) { if ($down) { $target = FALSE; } else { $target = TRUE; } } $model = new Model_Migration(); $model->ensure_table_exists(); $manager = new Migration(NULL, $model); // Sync the available migrations with those in the db $manager->sync_migration_files()->set_dry_run($dry_run); try { // Run migrations for specified groups & versions $manager->run_migration($groups, $target); } catch (Migration_Exception $e) { echo View::factory('minion/db/exception')->set('migration', $e->get_migration())->set('error', $e->getMessage()); throw $e; } $view = View::factory('minion/db/run')->set('dry_run', $dry_run)->set('quiet', $quiet)->set('dry_run_sql', $manager->get_dry_run_sql())->set('executed_migrations', $manager->get_executed_migrations())->set('group_versions', $model->get_group_statuses()); return $view; }
function up() { echo "Starting Migration Proc ...<BR>"; //check if migration already had ran ... $migration = Migration::get()->filter('Name', $this->title)->first(); if (!$migration) { $requests = JobRegistrationRequest::get(); foreach ($requests as $request) { if (!empty($request->City)) { //create locations $location = new JobLocation(); $location->City = $request->City; $location->State = $request->State; $location->Country = $request->Country; $location->RequestID = $request->ID; $location->Write(); $request->LocationType = 'Various'; $request->Write(); } } $migration = new Migration(); $migration->Name = $this->title; $migration->Description = $this->description; $migration->Write(); } echo "Ending Migration Proc ...<BR>"; }
function plugin_barcode_install() { global $DB; $migration = new Migration(PLUGIN_BARCODE_VERSION); if (!file_exists(GLPI_PLUGIN_DOC_DIR . "/barcode")) { mkdir(GLPI_PLUGIN_DOC_DIR . "/barcode"); } $migration->renameTable("glpi_plugin_barcode_config", "glpi_plugin_barcode_configs"); if (!TableExists("glpi_plugin_barcode_configs")) { $query = "CREATE TABLE `glpi_plugin_barcode_configs` (\n `id` int(11) NOT NULL auto_increment,\n `type` varchar(20) collate utf8_unicode_ci default NULL,\n PRIMARY KEY (`ID`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query) or die("error creating glpi_plugin_barcode_configs " . $DB->error()); $query = "INSERT INTO `glpi_plugin_barcode_configs` \n (`id`, `type`)\n VALUES\n ('1', 'code128')"; $DB->query($query) or die("error populate glpi_plugin_barcode_configs " . $DB->error()); } $migration->renameTable("glpi_plugin_barcode_config_type", "glpi_plugin_barcode_configs_types"); if (!TableExists("glpi_plugin_barcode_configs_types")) { $query = "CREATE TABLE `glpi_plugin_barcode_configs_types` (\n `id` int(11) NOT NULL auto_increment,\n `type` varchar(20) collate utf8_unicode_ci default NULL,\n `size` varchar(20) collate utf8_unicode_ci default NULL,\n `orientation` varchar(9) collate utf8_unicode_ci default NULL,\n `marginTop` int(11) NULL,\n `marginBottom` int(11) NULL,\n `marginLeft` int(11) NULL,\n `marginRight` int(11) NULL,\n `marginHorizontal` int(11) NULL,\n `marginVertical` int(11) NULL,\n `maxCodeWidth` int(11) NULL,\n `maxCodeHeight` int(11) NULL,\n PRIMARY KEY (`ID`),\n UNIQUE (`type`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; $DB->query($query) or die("error creating glpi_plugin_barcode_configs_types " . $DB->error()); $query = "INSERT INTO `glpi_plugin_barcode_configs_types`\n (`type`, `size`, `orientation`,\n `marginTop`, `marginBottom`, `marginLeft`, `marginRight`,\n `marginHorizontal`, `marginVertical`, `maxCodeWidth`, `maxCodeHeight`)\n VALUES\n ('Code39', 'A4', 'Portrait',\n '30', '30', '30', '30',\n '25', '30', '128', '50'),\n ('code128', 'A4', 'Portrait',\n '30', '30', '30', '30',\n '25', '30', '110', '70'),\n ('ean13', 'A4', 'Portrait',\n '30', '30', '30', '30',\n '25', '30', '110', '70'),\n ('int25', 'A4', 'Portrait',\n '30', '30', '30', '30',\n '25', '30', '110', '70'),\n ('postnet', 'A4', 'Portrait',\n '30', '30', '30', '30',\n '25', '30', '110', '70'),\n ('upca', 'A4', 'Portrait',\n '30', '30', '30', '30',\n '25', '30', '110', '70'),\n ('QRcode', 'A4', 'Portrait',\n '30', '30', '30', '30',\n '25', '30', '110', '100')"; $DB->query($query) or die("error populate glpi_plugin_barcode_configs_types " . $DB->error()); } if (countElementsInTable("glpi_plugin_barcode_configs_types", "`type`='QRcode'") == 0) { $query = "INSERT INTO `glpi_plugin_barcode_configs_types`\n (`type`, `size`, `orientation`,\n `marginTop`, `marginBottom`, `marginLeft`, `marginRight`,\n `marginHorizontal`, `marginVertical`, `maxCodeWidth`, `maxCodeHeight`)\n VALUES\n ('QRcode', 'A4', 'Portrait',\n '30', '30', '30', '30',\n '25', '30', '110', '100')"; $DB->query($query) or die("error populate glpi_plugin_barcode_configs_types " . $DB->error()); } include_once GLPI_ROOT . '/plugins/barcode/inc/profile.class.php'; include_once GLPI_ROOT . '/plugins/barcode/inc/config.class.php'; PluginBarcodeProfile::initProfile(); if (TableExists("glpi_plugin_barcode_profiles")) { $query = "DROP TABLE `glpi_plugin_barcode_profiles`"; $DB->query($query) or die("error deleting glpi_plugin_barcode_profiles"); } return true; }
function up() { echo "Starting Migration Proc ...<BR>"; //check if migration already had ran ... $migration = Migration::get()->filter('Name', $this->title)->first(); if (!$migration) { $presentation_type = SummitEventType::get("SummitEventType", "Type = 'Presentation' AND SummitID = 5")->first(); if ($presentation_type) { $presentation_type_id = $presentation_type->ID; } else { $presentation_type = new SummitEventType(); $presentation_type->Type = 'Presentation'; $presentation_type->SummitID = 5; $presentation_type->Color = '#D0A9F5'; $presentation_type_id = $presentation_type->Write(); } $SQL = <<<SQL UPDATE SummitEvent SET TypeID = {$presentation_type_id} WHERE ClassName = 'Presentation' AND SummitID = 5; SQL; DB::query($SQL); $migration = new Migration(); $migration->Name = $this->title; $migration->Description = $this->description; $migration->Write(); } echo "Ending Migration Proc ...<BR>"; }
function plugin_vip_install() { global $DB; $migration = new Migration(100); // Création de la table uniquement lors de la première installation if (!TableExists("glpi_plugin_vip_profiles")) { // Table des droits du profil $query = "CREATE TABLE `glpi_plugin_vip_profiles` (\n\t `id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_profiles (id)',\n\t `show_vip_tab` tinyint(1) collate utf8_unicode_ci default NULL,\n\t PRIMARY KEY (`id`)\n\t ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query) or die("Error creating Vip Profiles table" . $DB->error()); $migration->executeMigration(); //creation du premier accès nécessaire lors de l'installation du plugin include_once GLPI_ROOT . "/plugins/vip/inc/profile.class.php"; PluginVipProfile::createAdminAccess($_SESSION['glpiactiveprofile']['id']); } if (!TableExists("glpi_plugin_vip_groups")) { // $query = "CREATE TABLE `glpi_plugin_vip_groups` (\n `id` int(11) NOT NULL default 0 COMMENT 'RELATION to glpi_groups(id)',\n `isvip` tinyint(1) default '0',\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query) or die("Erreur lors de la création de la table des groupes vip " . $DB->error()); $query = "INSERT INTO `glpi_plugin_vip_groups`\n (`id`, `isvip`)\n VALUES ('0', '0')"; $DB->query($query) or die("Erreur lors de l'insertion des valeurs par défaut dans la table des groupes vip " . $DB->error()); } if (!TableExists("glpi_plugin_vip_tickets")) { $query = "CREATE TABLE glpi_plugin_vip_tickets (\n\t\t\t\t id int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_tickets (id)',\n\t\t\t\t isvip tinyint(1) default '0',\n\t\t\t\t PRIMARY KEY (`id`)\n\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query) or die("Error creating Vip Tickets table"); } $query = "INSERT INTO glpi_plugin_vip_tickets\n\t\t\t\t SELECT id, '0'\n\t\t\t\t\t FROM glpi_tickets\n\t\t ON DUPLICATE KEY\n\t\t\t\t UPDATE isvip = '0'"; $DB->query($query) or die("Error inserting ticket in Vip Tickets table"); $migration->executeMigration(); return true; }
function createFromTable($tablename, $include_data = false, $where) { //check the table exists $db = $this->db; $query = 'SELECT relname FROM pg_class WHERE relname=' . $db->qstr($tablename); $result = $db->GetOne($query); if ($result === false) { throw new Exception('Cannot Create migration from table ' . $tablename . ' as it doesn\'t exist'); } $migration = new Migration(); $table = $migration->add(new CreateTableComponent()); $table->name = $tablename; $references = $this->GetForeignKeys($tablename); $columns = $db->MetaColumns($tablename); foreach ($columns as $column_data) { $column_data->references = $references[$column_data->name]; $column = new AddColumnComponent($column_data); $table->addColumn($column); } $pks = $db->MetaPrimaryKeys($tablename); $table->setPrimaryKeys($pks); if ($include_data) { $query = 'SELECT * FROM ' . $tablename . ($where != '' ? ' WHERE ' . $where : ''); $insert_data = $migration->add(new InsertDataComponent($tablename)); $insert_data->setDB($db); $result = $db->Execute($query) or die($db->ErrorMsg() . $query); foreach ($result as $key => $row) { $insert_data->addRow($row); } } return $migration->toArray(); }
/** * Install * * @return bool for success (will die for most error) * */ function install() { global $DB; $migration = new Migration(100); // Install script $DB->runFile(GLPI_ROOT . "/plugins/consumables/install/sql/empty-1.0.0.sql"); // Notification // Request $query_id = "INSERT INTO `glpi_notificationtemplates`(`name`, `itemtype`, `date_mod`, `comment`, `css`) VALUES ('Consumables Request','PluginConsumablesRequest', NOW(),'','');"; $result = $DB->query($query_id) or die($DB->error()); $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginConsumablesRequest' AND `name` = 'Consumables Request'"; $result = $DB->query($query_id) or die($DB->error()); $itemtype = $DB->result($result, 0, 'id'); $query = "INSERT INTO `glpi_notificationtemplatetranslations`\r\nVALUES(NULL, '" . $itemtype . "', '','##consumable.action## : ##consumable.entity##',\r\n'##lang.consumable.entity## :##consumable.entity##\r\n##lang.consumablerequest.requester## : ##consumablerequest.requester##\t\r\n##lang.consumablerequest.consumabletype## : ##consumablerequest.consumabletype##\t\r\n##lang.consumablerequest.consumable## : ##consumablerequest.consumable##\r\n##lang.consumablerequest.number## : ##consumablerequest.number##\r\n##lang.consumablerequest.request_date## : ##consumablerequest.request_date##\r\n##lang.consumablerequest.status## : ##consumablerequest.status##',\r\n'<p>##lang.consumable.entity## :##consumable.entity##<br /> <br />\r\n##lang.consumablerequest.requester## : ##consumablerequest.requester##<br />\t\r\n##lang.consumablerequest.consumabletype## : ##consumablerequest.consumabletype##<br />\r\n##lang.consumablerequest.consumable## : ##consumablerequest.consumable##<br />\r\n##lang.consumablerequest.number## : ##consumablerequest.number##<br />\r\n##lang.consumablerequest.request_date## : ##consumablerequest.request_date##<br />\r\n##lang.consumablerequest.status## : ##consumablerequest.status##<br />');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\r\n VALUES (NULL, 'Consumable request', 0, 'PluginConsumablesRequest', 'ConsumableRequest',\r\n 'mail','" . $itemtype . "', '', 1, 1, '" . date('Y-m-d H:i:s') . "');"; $result = $DB->query($query); // Request validation $query_id = "INSERT INTO `glpi_notificationtemplates`(`name`, `itemtype`, `date_mod`, `comment`, `css`) VALUES ('Consumables Request Validation','PluginConsumablesRequest', NOW(),'','');"; $result = $DB->query($query_id) or die($DB->error()); $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginConsumablesRequest' AND `name` = 'Consumables Request Validation'"; $result = $DB->query($query_id) or die($DB->error()); $itemtype = $DB->result($result, 0, 'id'); $query = "INSERT INTO `glpi_notificationtemplatetranslations`\r\nVALUES(NULL, '" . $itemtype . "', '','##consumable.action## : ##consumable.entity##',\r\n'##lang.consumable.entity## :##consumable.entity##\r\n##lang.consumablerequest.requester## : ##consumablerequest.requester##\t\r\n##lang.consumablerequest.validator## : ##consumablerequest.validator##\t\r\n##lang.consumablerequest.consumabletype## : ##consumablerequest.consumabletype##\t\r\n##lang.consumablerequest.consumable## : ##consumablerequest.consumable##\r\n##lang.consumablerequest.number## : ##consumablerequest.number##\r\n##lang.consumablerequest.request_date## : ##consumablerequest.request_date##\r\n##lang.consumablerequest.status## : ##consumablerequest.status##\r\n##lang.consumablerequest.comment## : ##consumablerequest.comment##',\r\n'<p>##lang.consumable.entity## :##consumable.entity##<br /> <br />\r\n##lang.consumablerequest.requester## : ##consumablerequest.requester##<br />\t\r\n##lang.consumablerequest.validator## : ##consumablerequest.validator##<br />\r\n##lang.consumablerequest.consumabletype## : ##consumablerequest.consumabletype##<br />\r\n##lang.consumablerequest.consumable## : ##consumablerequest.consumable##<br />\r\n##lang.consumablerequest.number## : ##consumablerequest.number##<br />\r\n##lang.consumablerequest.request_date## : ##consumablerequest.request_date##<br />\r\n##lang.consumablerequest.status## : ##consumablerequest.status##<br />\r\n##lang.consumablerequest.comment## : ##consumablerequest.comment##<br />');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\r\n VALUES (NULL, 'Consumable request validation', 0, 'PluginConsumablesRequest', 'ConsumableResponse',\r\n 'mail','" . $itemtype . "','', 1, 1, '" . date('Y-m-d H:i:s') . "');"; $result = $DB->query($query); $migration->executeMigration(); return true; }
function plugin_moreticket_install() { global $DB; include_once GLPI_ROOT . "/plugins/moreticket/inc/profile.class.php"; if (!TableExists("glpi_plugin_moreticket_configs")) { // table sql creation $DB->runFile(GLPI_ROOT . "/plugins/moreticket/sql/empty-1.2.0.sql"); } PluginMoreticketProfile::initProfile(); PluginMoreticketProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']); $migration = new Migration("1.1.0"); $migration->dropTable('glpi_plugin_moreticket_profiles'); if (!FieldExists("glpi_plugin_moreticket_configs", "solution_status")) { $DB->runFile(GLPI_ROOT . "/plugins/moreticket/sql/update-1.1.1.sql"); } if (FieldExists("glpi_plugin_moreticket_waitingtypes", "is_helpdeskvisible")) { $DB->runFile(GLPI_ROOT . "/plugins/moreticket/sql/update-1.1.2.sql"); } if (!FieldExists("glpi_plugin_moreticket_closetickets", "documents_id")) { $DB->runFile(GLPI_ROOT . "/plugins/moreticket/sql/update-1.1.3.sql"); } if (!FieldExists("glpi_plugin_moreticket_configs", "date_report_mandatory")) { $DB->runFile(GLPI_ROOT . "/plugins/moreticket/sql/update-1.2.0.sql"); } return true; }
public static function install(Migration $migration) { global $DB; $table = getTableForItemType(__CLASS__); if (!TableExists($table)) { $query = "CREATE TABLE IF NOT EXISTS `{$table}` (\n `id` int(11) NOT NULL auto_increment,\n `entities_id` int(11) NOT NULL DEFAULT '0',\n `is_recursive` tinyint(1) NOT NULL DEFAULT '1',\n `name` varchar(255) NOT NULL DEFAULT '',\n `comment` text collate utf8_unicode_ci,\n `color` varchar(50) NOT NULL DEFAULT '' COLLATE 'utf8_unicode_ci',\n PRIMARY KEY (`id`),\n KEY `name` (`name`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $GLOBALS['DB']->query($query) or die($GLOBALS['DB']->error()); } if (!FieldExists($table, 'type_menu')) { $migration->addField($table, 'type_menu', "varchar(50) NOT NULL DEFAULT ''"); $migration->addKey($table, 'type_menu'); $migration->migrationOneTable($table); } // Version 0.90-1.1 $result = $DB->query("SHOW FIELDS FROM `{$table}` where Field ='type_menu'"); if ($result && $DB->numrows($result)) { while ($data = $DB->fetch_assoc($result)) { if (stristr($data["Type"], 'varchar') !== FALSE) { $DB->query("ALTER TABLE `{$table}` DROP INDEX `type_menu`;"); $DB->query("ALTER TABLE `{$table}` MODIFY `type_menu` text COLLATE utf8_unicode_ci;"); $datas = getAllDatasFromTable($table, "`type_menu` IS NOT NULL"); if (!empty($datas)) { foreach ($datas as $data) { $itemtypes = PluginTagTagItem::getItemtypes($data['type_menu']); $DB->query("UPDATE `{$table}` SET `type_menu` = '" . json_encode($itemtypes) . "' WHERE `id` = '" . $data['id'] . "'"); } } break; } } } return true; }
public static function install(Migration $migration) { $table = getTableForItemType(__CLASS__); if (!TableExists($table)) { $migration->displayMessage("Installing {$table}"); $query = "CREATE TABLE IF NOT EXISTS `{$table}` (\n `id` int(11) NOT NULL auto_increment,\n `name` varchar(255) NOT NULL DEFAULT '',\n `comment` text collate utf8_unicode_ci,\n PRIMARY KEY (`id`),\n KEY `name` (`name`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $GLOBALS['DB']->query($query) or die($GLOBALS['DB']->error()); } // Migration from previous version if (TableExists('glpi_plugin_formcreator_cats')) { $query = "INSERT IGNORE INTO `{$table}` (`id`, `name`)\n SELECT `id`,`name` FROM glpi_plugin_formcreator_cats"; $GLOBALS['DB']->query($query); $GLOBALS['DB']->query("DROP TABLE glpi_plugin_formcreator_cats"); } /** * Migration of special chars from previous versions * * @since 0.85-1.2.3 */ $query = "SELECT `id`, `name`, `comment`\n FROM `{$table}`"; $result = $GLOBALS['DB']->query($query); while ($line = $GLOBALS['DB']->fetch_array($result)) { $query_update = 'UPDATE `' . $table . '` SET `name` = "' . plugin_formcreator_encode($line['name']) . '", `comment` = "' . plugin_formcreator_encode($line['comment']) . '" WHERE `id` = ' . $line['id']; $GLOBALS['DB']->query($query_update) or die($GLOBALS['DB']->error()); } return true; }
function up() { echo "Starting Migration Proc ...<BR>"; //check if migration already had ran ... $migration = DataObject::get_one("Migration", "Name='{$this->title}'"); if (!$migration) { //first we add the platform InteropProgramType $platform = InteropProgramType::get("InteropProgramType", "ShortName = 'Platform'")->first(); if (!$platform) { $platform = new InteropProgramType(); $platform->Name = 'OpenStack Powered Platform'; $platform->ShortName = 'Platform'; $platform->HasCapabilities = true; $platform->Order = 1; $platform->write(); $platform = InteropProgramType::get("InteropProgramType", "ShortName = 'Platform'")->first(); } //then migrate the old InteropProgramType relations with capability and designated sections $relations = DB::query('SELECT cap.ID AS capID, pt.ID AS ptID, pv.ID AS pvID, cap.Order AS capOrder FROM InteropCapability AS cap LEFT JOIN InteropProgramType AS pt ON cap.ProgramID = pt.ID LEFT JOIN InteropProgramVersion AS pv ON cap.VersionID = pv.ID'); foreach ($relations as $relation) { $capability = InteropCapability::get_by_id('InteropCapability', $relation['capID']); $program = InteropProgramType::get_by_id('InteropProgramType', $relation['ptID']); $version = InteropProgramVersion::get_by_id('InteropProgramVersion', $relation['pvID']); $capability->Program()->add($program); $capability->Program()->add($platform); $capability->Version()->add($version, array('Order' => $relation['capOrder'])); $capability->write(); } $relations = DB::query('SELECT ds.ID AS dsID, pt.ID AS ptID, pv.ID AS pvID, ds.Order AS dsOrder FROM InteropDesignatedSection AS ds LEFT JOIN InteropProgramType AS pt ON ds.ProgramID = pt.ID LEFT JOIN InteropProgramVersion AS pv ON ds.VersionID = pv.ID'); foreach ($relations as $relation) { $dsection = InteropDesignatedSection::get_by_id('InteropDesignatedSection', $relation['dsID']); $program = InteropProgramType::get_by_id('InteropProgramType', $relation['ptID']); $version = InteropProgramVersion::get_by_id('InteropProgramVersion', $relation['pvID']); $dsection->Program()->add($program); $dsection->Program()->add($platform); $dsection->Version()->add($version, array('Order' => $relation['dsOrder'])); $dsection->write(); } //finally remove ProgramID and VersionID column from capability and designatedsection DB::query('ALTER TABLE InteropCapability DROP COLUMN ProgramID'); DB::query('ALTER TABLE InteropDesignatedSection DROP COLUMN ProgramID'); DB::query('ALTER TABLE InteropCapability DROP COLUMN VersionID'); DB::query('ALTER TABLE InteropDesignatedSection DROP COLUMN VersionID'); DB::query('ALTER TABLE InteropCapability DROP COLUMN `Order`'); DB::query('ALTER TABLE InteropDesignatedSection DROP COLUMN `Order`'); $migration = new Migration(); $migration->Name = $this->title; $migration->Description = $this->description; $migration->Write(); } echo "Ending Migration Proc ...<BR>"; }
public function testCatchException() { /** @var \Magento\Framework\App\Bootstrap|\PHPUnit_Framework_TestCase $bootstrap */ $bootstrap = $this->getMock('Magento\\Framework\\App\\Bootstrap', [], [], '', false); /** @var \Exception|\PHPUnit_Framework_TestCase $exception */ $exception = $this->getMock('\\Exception', [], [], '', false); $result = $this->migration->catchException($bootstrap, $exception); $this->assertFalse($result); }
static function install(Migration $migration) { $table = getTableForItemType(__CLASS__); $migration->displayMessage("Installing {$table}"); if (!TableExists($table)) { $query = "CREATE TABLE IF NOT EXISTS `{$table}` (\n `plugin_formcreator_forms_id` INT NOT NULL ,\n `plugin_formcreator_profiles_id` INT NOT NULL ,\n PRIMARY KEY (`plugin_formcreator_forms_id`, `plugin_formcreator_profiles_id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $GLOBALS['DB']->query($query) or die($GLOBALS['DB']->error()); } return true; }
public static function install(Migration $migration) { $table = getTableForItemType(__CLASS__); if (!TableExists($table)) { $migration->displayMessage("Installing {$table}"); $query = "CREATE TABLE IF NOT EXISTS `{$table}` (\n\t\t\t\t\t `id` int(11) NOT NULL auto_increment,\n\t\t\t\t\t `plugin_formcreator_forms_id` int(11) NOT NULL default '0',\n\t\t\t\t\t `items_id` int(11) NOT NULL default '0',\n\t\t\t\t\t `itemtype` varchar(100) collate utf8_unicode_ci NOT NULL default '',\n\t\t\t\t\t PRIMARY KEY (`id`),\n\t\t\t\t\t UNIQUE KEY `unicity` (`plugin_formcreator_forms_id`,`items_id`,`itemtype`),\n\t\t\t\t\t KEY `plugin_formcreator_forms_id` (`plugin_formcreator_forms_id`),\n\t\t\t\t\t KEY `item` (`itemtype`,`items_id`)\n\t\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $GLOBALS['DB']->query($query) or die($GLOBALS['DB']->error()); } return true; }
static function install(Migration $migration) { global $DB; $table = getTableForItemType(__CLASS__); if (!TableExists($table)) { $migration->displayMessage("Installing {$table}"); $query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_order_billtypes` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,\n `comment` text COLLATE utf8_unicode_ci,\n PRIMARY KEY (`id`),\n KEY `name` (`name`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ;"; $DB->query($query) or die($DB->error()); } }
static function install(Migration $migration) { global $DB; $obj = new self(); $table = $obj->getTable(); if (!TableExists($table)) { $migration->displayMessage("Installing {$table}"); $query = "CREATE TABLE IF NOT EXISTS `{$table}` (\n `id` INT(11) NOT NULL auto_increment,\n `name` VARCHAR(255) DEFAULT NULL,\n `label` VARCHAR(255) DEFAULT NULL,\n `type` VARCHAR(25) DEFAULT NULL,\n `plugin_fields_containers_id` INT(11) NOT NULL DEFAULT '0',\n `ranking` INT(11) NOT NULL DEFAULT '0',\n `default_value` VARCHAR(255) DEFAULT NULL,\n `is_active` TINYINT(1) NOT NULL DEFAULT '1',\n `is_readonly` TINYINT(1) NOT NULL DEFAULT '1',\n `mandatory` TINYINT(1) NOT NULL DEFAULT '0',\n PRIMARY KEY (`id`),\n KEY `plugin_fields_containers_id` (`plugin_fields_containers_id`),\n KEY `is_active` (`is_active`),\n KEY `is_readonly` (`is_readonly`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; $DB->query($query) or die($DB->error()); } $migration->displayMessage("Updating {$table}"); if (!FieldExists($table, 'is_active')) { $migration->addField($table, 'is_active', 'bool', array('value' => 1)); $migration->addKey($table, 'is_active', 'is_active'); } if (!FieldExists($table, 'is_readonly')) { $migration->addField($table, 'is_readonly', 'bool', array('default' => false)); $migration->addKey($table, 'is_readonly', 'is_readonly'); } if (!FieldExists($table, 'mandatory')) { $migration->addField($table, 'mandatory', 'bool', array('value' => 0)); } $migration->executeMigration(); return true; }
function plugin_mreporting_install() { global $DB; //get version $plugin = new Plugin(); $found = $plugin->find("name = 'mreporting'"); $plugin_mreporting = array_shift($found); //init migration $migration = new Migration($plugin_mreporting['version']); //create profiles table $queries = array(); $queries[] = "CREATE TABLE IF NOT EXISTS `glpi_plugin_mreporting_profiles` (\n `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,\n `profiles_id` VARCHAR(45) NOT NULL,\n `reports` CHAR(1),\n `config` CHAR(1),\n PRIMARY KEY (`id`)\n )\n ENGINE = MyISAM;"; //create configuration table $queries[] = "CREATE TABLE IF NOT EXISTS `glpi_plugin_mreporting_configs` (\n `id` int(11) NOT NULL auto_increment,\n `name` varchar(255) collate utf8_unicode_ci default NULL,\n `classname` varchar(255) collate utf8_unicode_ci default NULL,\n `is_active` tinyint(1) NOT NULL default '0',\n `is_notified` tinyint(1) NOT NULL default '1',\n `show_graph` tinyint(1) NOT NULL default '0',\n `show_area` tinyint(1) NOT NULL default '0',\n `spline` tinyint(1) NOT NULL default '0',\n `show_label` VARCHAR(10) default NULL,\n `flip_data` tinyint(1) NOT NULL default '0',\n `unit` VARCHAR(10) default NULL,\n `default_delay` VARCHAR(10) default NULL,\n `condition` VARCHAR(255) default NULL,\n `graphtype` VARCHAR(255) default 'GLPI',\n PRIMARY KEY (`id`),\n KEY `is_active` (`is_active`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; $queries[] = "CREATE TABLE IF NOT EXISTS `glpi_plugin_mreporting_preferences` (\n `id` int(11) NOT NULL auto_increment,\n `users_id` int(11) NOT NULL default 0,\n `template` varchar(255) collate utf8_unicode_ci default NULL,\n PRIMARY KEY (`id`),\n KEY `users_id` (`users_id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; // add display preferences $query_display_pref = "SELECT id \n FROM glpi_displaypreferences\n WHERE itemtype = 'PluginMreportingConfig'"; $res_display_pref = $DB->query($query_display_pref); if ($DB->numrows($res_display_pref) == 0) { $queries[] = "INSERT INTO `glpi_displaypreferences` \n VALUES (NULL,'PluginMreportingConfig','2','2','0');"; $queries[] = "INSERT INTO `glpi_displaypreferences` \n VALUES (NULL,'PluginMreportingConfig','3','3','0');"; $queries[] = "INSERT INTO `glpi_displaypreferences` \n VALUES (NULL,'PluginMreportingConfig','4','4','0');"; $queries[] = "INSERT INTO `glpi_displaypreferences` \n VALUES (NULL,'PluginMreportingConfig','5','5','0');"; $queries[] = "INSERT INTO `glpi_displaypreferences` \n VALUES (NULL,'PluginMreportingConfig','6','6','0');"; $queries[] = "INSERT INTO `glpi_displaypreferences` \n VALUES (NULL,'PluginMreportingConfig','8','8','0');"; } $queries[] = "CREATE TABLE IF NOT EXISTS `glpi_plugin_mreporting_notifications` (\n `id` int(11) NOT NULL auto_increment,\n `entities_id` int(11) NOT NULL default '0',\n `is_recursive` tinyint(1) NOT NULL default '0',\n `name` varchar(255) collate utf8_unicode_ci default NULL,\n `notepad` longtext collate utf8_unicode_ci,\n `date_envoie` DATE DEFAULT NULL,\n `notice`INT(11) NOT NULL DEFAULT 0,\n `alert` INT(11) NOT NULL DEFAULT 0,\n `comment` text collate utf8_unicode_ci,\n `date_mod` datetime default NULL,\n `is_deleted` tinyint(1) NOT NULL default '0',\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; foreach ($queries as $query) { $DB->query($query); } // == Update to 2.1 == if (!FieldExists('glpi_plugin_mreporting_configs', 'is_notified')) { $migration->addField('glpi_plugin_mreporting_configs', 'is_notified', 'tinyint(1) NOT NULL default "1"', array('after' => 'is_active')); $migration->migrationOneTable('glpi_plugin_mreporting_configs'); } require_once "inc/profile.class.php"; PluginMreportingProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']); $rep_files_mreporting = GLPI_PLUGIN_DOC_DIR . "/mreporting"; if (!is_dir($rep_files_mreporting)) { mkdir($rep_files_mreporting); } $notifications_folder = GLPI_PLUGIN_DOC_DIR . "/mreporting/notifications"; if (!is_dir($notifications_folder)) { mkdir($notifications_folder); } require_once "inc/notification.class.php"; PluginMreportingNotification::install(); CronTask::Register('PluginMreportingNotification', 'SendNotifications', MONTH_TIMESTAMP); require_once "inc/baseclass.class.php"; require_once "inc/common.class.php"; require_once "inc/config.class.php"; $config = new PluginMreportingConfig(); $config->createFirstConfig(); return true; }
static function install(Migration $migration) { global $DB; //Only avaiable since 1.3.0 $table = getTableForItemType(__CLASS__); if (!TableExists($table)) { $migration->displayMessage("Installing {$table}"); $query = "CREATE TABLE `glpi_plugin_order_ordertypes` (\n `id` int(11) NOT NULL auto_increment,\n `name` varchar(255) collate utf8_unicode_ci default NULL,\n `comment` text collate utf8_unicode_ci,\n PRIMARY KEY (`id`),\n KEY `name` (`name`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; $DB->query($query) or die($DB->error()); } }
static function install(Migration $migration) { global $DB; if (!$DB->query("CREATE TABLE IF NOT EXISTS `glpi_plugin_talk_userprefs` (\n `id` INT(11) NOT NULL auto_increment,\n `users_id` INT(11) NOT NULL default '0',\n `talk_tab` TINYINT(1) NOT NULL default '1',\n `old_tabs` TINYINT(1) NOT NULL default '1',\n `split_view` TINYINT(1) NOT NULL default '0',\n PRIMARY KEY (`id`),\n UNIQUE KEY (`users_id`),\n KEY `talk_tab` (`talk_tab`),\n KEY `split_view` (`split_view`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci")) { return false; } if (!FieldExists('glpi_plugin_talk_userprefs', 'old_tabs')) { $migration->addField('glpi_plugin_talk_userprefs', 'old_tabs', 'bool'); $migration->migrationOneTable('glpi_plugin_talk_userprefs'); } }
/** * * 在数据迁移表中创建指定版本的数据 */ public function checkMigration($version, $module, $apply_time) { //插入需要的数据 $migration_data = $this->findByVersionAndModule($version, $module); if (empty($migration_data)) { $migration = new Migration(); $migration->version = $version; $migration->apply_time = $apply_time; $migration->module = $module; $migration->save(); } }
static function install(Migration $migration) { global $DB; $obj = new self(); $table = $obj->getTable(); if (!TableExists($table)) { $migration->displayMessage("Installing {$table}"); $query = "CREATE TABLE IF NOT EXISTS `{$table}` (\n `id` INT(11) NOT NULL auto_increment,\n `profiles_id` INT(11) NOT NULL DEFAULT '0',\n `plugin_fields_containers_id` INT(11) NOT NULL DEFAULT '0',\n `right` CHAR(1) DEFAULT NULL,\n PRIMARY KEY (`id`),\n KEY `profiles_id` (`profiles_id`),\n KEY `plugin_fields_containers_id` (`plugin_fields_containers_id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; $DB->query($query) or die($DB->error()); } return true; }