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 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('Training', 'Public Cloud', 'Appliance', 'Distribution', 'Consultant'); $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("ALTER TABLE `OpenStackRelease_OpenStackComponents`\n\t\t\tADD UNIQUE INDEX `Release_Component` (`OpenStackReleaseID` ASC, `OpenStackComponentID` ASC);"); DB::query("ALTER TABLE `CloudServiceOffered_PricingSchemas`\n\t\t\tADD UNIQUE INDEX `CloudServiceOffered_PricingSchemaType` (`CloudServiceOfferedID` ASC, `PricingSchemaTypeID` ASC);"); $migration = new Migration(); $migration->Name = $this->title; $migration->Description = $this->description; $migration->Write(); } echo "Ending Migration Proc ...<BR>"; }