本文整理汇总了PHP中Migration::Write方法的典型用法代码示例。如果您正苦于以下问题:PHP Migration::Write方法的具体用法?PHP Migration::Write怎么用?PHP Migration::Write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Migration
的用法示例。
在下文中一共展示了Migration::Write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: up
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>";
}
示例2: up
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>";
}
示例3: up
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>";
}
示例4: up
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>";
}
示例5: up
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>";
}
示例6: up
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>";
}
示例7: up
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>";
}
示例8: up
function up()
{
echo "Starting Migration Proc ...<BR>";
//check if migration already had ran ...
$migration = Migration::get()->filter('Name', $this->title)->first();
if (!$migration) {
DB::query("update JobPage set active =1;");
DB::query("update JobPage set ExpirationDate = DATE_ADD(JobPostedDate, INTERVAL 2 MONTH)\nwhere JobPage.JobPostedDate IS NOT NULL;");
$migration = new Migration();
$migration->Name = $this->title;
$migration->Description = $this->description;
$migration->Write();
}
echo "Ending Migration Proc ...<BR>";
}
示例9: up
function up()
{
echo sprintf("starting migration # %s ...", $this->title) . PHP_EOL;
//check if migration already had ran ...
$migration = Migration::get()->filter('Name', $this->title)->first();
if (!$migration) {
$this->doUp();
$migration = new Migration();
$migration->Name = $this->title;
$migration->Description = $this->description;
$migration->Write();
echo sprintf("ending migration # %s ...", $this->title) . PHP_EOL;
} else {
echo sprintf("migration # %s already ran !...", $this->title) . PHP_EOL;
}
}
示例10: up
function up()
{
echo "Starting Migration Proc ...<BR>";
$migration = Migration::get()->filter('Name', $this->title)->first();
if (!$migration) {
$migration = new Migration();
$migration->Name = $this->title;
$migration->Description = $this->description;
$migration->Write();
//run migration
$query = "UPDATE Deployment, (\n SELECT Org.ID AS OrgID, Deployment.ID AS DepID\n FROM Org, Deployment, DeploymentSurvey, Member\n WHERE\n Member.ID = DeploymentSurvey.MemberID AND\n Org.ID = Member.OrgID AND\n Deployment.DeploymentSurveyID = DeploymentSurvey.ID\n ) AS t1\n SET Deployment.OrgID = t1.OrgID\n WHERE t1.DepID = Deployment.ID";
DB::query($query);
} else {
echo "Migration Already Ran! <BR>";
}
echo "Migration Done <BR>";
}
示例11: up
function up()
{
echo "Starting Migration Proc ...<BR>";
//check if migration already had ran ...
$migration = DataObject::get_one("Migration", "Name='{$this->title}'");
if (!$migration) {
$g = new Group();
$g->setTitle('Community Members');
$g->setDescription('Community Members');
$g->setSlug(IFoundationMember::CommunityMemberGroupSlug);
$g->write();
$migration = new Migration();
$migration->Name = $this->title;
$migration->Description = $this->description;
$migration->Write();
}
echo "Ending Migration Proc ...<BR>";
}
示例12: up
function up()
{
echo "Starting Migration Proc ...<BR>";
//check if migration already had ran ...
$migration = Migration::get()->filter('Name', $this->title)->first();
if (!$migration) {
$g = new Group();
$g->setTitle('CCLA Admin');
$g->setDescription('Company CCLA Admin');
$g->setSlug(ICLAMemberDecorator::CCLAGroupSlug);
$g->write();
Permission::grant($g->getIdentifier(), ICLAMemberDecorator::CCLAPermissionSlug);
$migration = new Migration();
$migration->Name = $this->title;
$migration->Description = $this->description;
$migration->Write();
}
echo "Ending Migration Proc ...<BR>";
}
示例13: up
function up()
{
echo "Starting Migration Proc ...<BR>";
//check if migration already had ran ...
$migration = DataObject::get_one("Migration", "Name='{$this->title}'");
if (!$migration) {
$result = News::get();
foreach ($result as $news) {
if (empty($news->DateEmbargo)) {
$news->DateEmbargo = $news->Date;
}
$news->Write();
}
$migration = new Migration();
$migration->Name = $this->title;
$migration->Description = $this->description;
$migration->Write();
}
echo "Ending Migration Proc ...<BR>";
}
示例14: up
function up()
{
echo "Starting Proc ...<BR>";
$migration = Migration::get()->filter('Name', $this->title)->first();
if (!$migration) {
$migration = new Migration();
$migration->Name = $this->title;
$migration->Description = $this->description;
$migration->Write();
//run migration
$surveys = DeploymentSurvey::get();
foreach ($surveys as $survey) {
$survey->SendDigest = 1;
$survey->write();
}
} else {
echo "Migration Already Ran! <BR>";
}
echo "Migration Done <BR>";
}
示例15: up
function up()
{
echo "Starting Migration Proc ...<BR>";
$migration = Migration::get()->filter('Name', $this->title)->first();
if (!$migration) {
//run migration
$query = <<<SQL
update SiteTree_Live
SET ClassName='AnniversaryPage'
where ID = 891;
SQL;
DB::query($query);
$migration = new Migration();
$migration->Name = $this->title;
$migration->Description = $this->description;
$migration->Write();
} else {
echo "Migration Already Ran! <BR>";
}
echo "Migration Done <BR>";
}