function doUp()
    {
        global $database;
        if (DBSchema::existsColumn($database, 'PresentationSpeaker', 'OnSitePhoneNumber')) {
            $speakers_info_query = <<<SQL
SELECT ID, OnSitePhoneNumber, ConfirmedDate, RegisteredForSummit
FROM PresentationSpeaker where OnSitePhoneNumber IS NOT NULL;
SQL;
            $res = DB::query($speakers_info_query);
            foreach ($res as $row) {
                $speaker_id = intval($row['ID']);
                $on_site_phone = intval($row['OnSitePhoneNumber']);
                $confirmed_date = $row['ConfirmedDate'];
                $registered = (bool) $row['RegisteredForSummit'];
                $speaker = PresentationSpeaker::get()->byID($speaker_id);
                if (is_null($speaker)) {
                    continue;
                }
                if (PresentationSpeakerSummitAssistanceConfirmationRequest::get()->filter(array('SummitID' => 5, 'SpeakerID' => $speaker_id))->count() > 0) {
                    continue;
                }
                $assistance = PresentationSpeakerSummitAssistanceConfirmationRequest::create();
                $assistance->SpeakerID = $speaker_id;
                $assistance->SummitID = 5;
                $assistance->OnSitePhoneNumber = $on_site_phone;
                $assistance->ConfirmationDate = $confirmed_date;
                $assistance->RegisteredForSummit = $registered;
                $assistance->IsConfirmed = true;
                $assistance->write();
            }
            DBSchema::dropColumn($database, 'PresentationSpeaker', 'OnSitePhoneNumber');
            DBSchema::dropColumn($database, 'PresentationSpeaker', 'ConfirmedDate');
            DBSchema::dropColumn($database, 'PresentationSpeaker', 'RegisteredForSummit');
        }
    }
 function doUp()
 {
     global $database;
     if (DBSchema::existsColumn($database, 'SummitRegistrationPromoCode', 'OwnerID')) {
         DBSchema::dropColumn($database, 'SummitRegistrationPromoCode', 'OwnerID');
     }
 }
 /**
  * Run the migration
  */
 public function doUp()
 {
     global $database;
     if (DBSchema::existsColumn($database, 'PresentationVideo', 'Processed')) {
         DB::query("UPDATE PresentationVideo SET Processed = 1");
     }
 }
 function doUp()
 {
     global $database;
     if (DBSchema::existsColumn($database, "EventbriteEvent", "ExternalOrderId")) {
         DBSchema::dropColumn($database, "EventbriteEvent", "ExternalOrderId");
     }
 }
 /**
  * Run the migration
  */
 public function doUp()
 {
     global $database;
     if (DBSchema::existsColumn($database, 'GerritChangeInfo', 'MemberID')) {
         DBSchema::dropColumn($database, 'GerritChangeInfo', 'MemberID');
     }
 }
 function doUp()
 {
     global $database;
     if (DBSchema::existsColumn($database, 'SummitPresentationComment', 'IsCategoryChangeSuggestion')) {
         DB::query("UPDATE SummitPresentationComment set IsCategoryChangeSuggestion = 1\nWHERE Body LIKE '%suggested that this presentation be moved to the category%';");
     }
 }
 function doUp()
 {
     global $database;
     if (DBSchema::existsColumn($database, 'Member', 'LegacyMember')) {
         DB::query("UPDATE Member SET LegacyMember = 1 ;");
         DB::query("UPDATE Member SET EmailVerified = 1, EmailVerifiedDate = NOW() WHERE LegacyMember = 1;");
     }
 }
 function doUp()
 {
     global $database;
     $columns = array('LastEdited', 'Created', 'Name', 'DisplayOnSite', 'Featured', 'City', 'Country', 'YouTubeID', 'URLSegment', 'StartTime', 'EndTime', 'Type', 'Location', 'Day', 'Speakers', 'SlidesLink', 'event_key', 'MemberID', 'IsKeynote');
     foreach ($columns as $column) {
         if (DBSchema::existsColumn($database, 'Presentation', $column)) {
             DB::query("ALTER TABLE Presentation DROP COLUMN {$column};");
         }
     }
 }
 function doUp()
 {
     global $database;
     global $database;
     $columns = array('Name', 'SchedUrl');
     foreach ($columns as $column) {
         if (DBSchema::existsColumn($database, 'Summit', $column)) {
             DB::query("ALTER TABLE Summit DROP COLUMN {$column};");
         }
     }
 }
 public function doUp()
 {
     global $database;
     if (DBSchema::existsColumn($database, 'SummitCategoryChange', 'Done')) {
         DB::query("UPDATE SummitCategoryChange SET Status = 1 WHERE Done=1");
         DB::query("UPDATE SummitCategoryChange SET Status = 0 WHERE Done=0");
     }
     DB::query("UPDATE SummitSelectedPresentation SET Collection = 'selected'");
     if (DBSchema::existsColumn($database, 'SummitPresentationComment', 'IsCategoryChangeSuggestion')) {
         DB::query("UPDATE SummitPresentationComment SET IsActivity = 1 WHERE IsCategoryChangeSuggestion = 1");
     }
 }
 /**
  * Run the migration
  */
 public function doUp()
 {
     global $database;
     if (DBSchema::existsColumn($database, 'Member', 'CLASigned')) {
         DBSchema::dropColumn($database, 'Member', 'CLASigned');
     }
     if (DBSchema::existsColumn($database, 'Member', 'GerritID')) {
         DBSchema::dropColumn($database, 'Member', 'GerritID');
     }
     if (DBSchema::existsColumn($database, 'Member', 'LastCodeCommit')) {
         DBSchema::dropColumn($database, 'Member', 'LastCodeCommit');
     }
 }
 function doUp()
 {
     global $database;
     if (DBSchema::existsColumn($database, 'SummitAttendee', 'TicketTypeID')) {
         DB::query("DELETE FROM SummitAttendee;");
         DB::query("UPDATE EventbriteEvent SET Processed = 0;");
         DB::query("ALTER TABLE SummitAttendee DROP COLUMN TicketTypeID;");
         DB::query("ALTER TABLE SummitAttendee DROP COLUMN ExternalTicketClassID;");
         DB::query("ALTER TABLE SummitAttendee DROP COLUMN ExternalOrderId;");
         DB::query("ALTER TABLE SummitAttendee DROP COLUMN TicketBoughtDate;");
         DB::query("ALTER TABLE SummitAttendee DROP COLUMN ExternalId;");
     }
 }
 function doUp()
 {
     global $database;
     if (!DBSchema::existsColumn($database, 'PresentationSpeaker', 'Expertise')) {
         return;
     }
     $speakers = DB::query("SELECT * FROM PresentationSpeaker WHERE Expertise IS NOT NULL");
     foreach ($speakers as $speaker) {
         $expertise_array = preg_split('/$\\R?^/m', $speaker['Expertise']);
         foreach ($expertise_array as $exp) {
             $new_exp = new SpeakerExpertise();
             $new_exp->Expertise = $exp;
             $new_exp->SpeakerID = $speaker['ID'];
             $new_exp->Write();
         }
     }
     DB::query("ALTER TABLE PresentationSpeaker DROP COLUMN Expertise");
 }
 function doUp()
 {
     global $database;
     if (DBSchema::existsColumn($database, 'PresentationSpeaker', 'SummitID')) {
         DBSchema::dropColumn($database, 'PresentationSpeaker', 'SummitID');
     }
     if (DBSchema::existsColumn($database, 'PresentationSpeaker', 'AnnouncementEmailTypeSent')) {
         DBSchema::dropColumn($database, 'PresentationSpeaker', 'AnnouncementEmailTypeSent');
     }
     if (DBSchema::existsColumn($database, 'PresentationSpeaker', 'AnnouncementEmailSentDate')) {
         DBSchema::dropColumn($database, 'PresentationSpeaker', 'AnnouncementEmailSentDate');
     }
     if (DBSchema::existsColumn($database, 'PresentationSpeaker', 'SummitRegistrationPromoCodeID')) {
         DBSchema::dropColumn($database, 'PresentationSpeaker', 'SummitRegistrationPromoCodeID');
     }
     if (DBSchema::existsColumn($database, 'PresentationSpeaker', 'TwitterHandle')) {
         DB::query('UPDATE PresentationSpeaker SET TwitterName = TwitterHandle;');
         DBSchema::dropColumn($database, 'PresentationSpeaker', 'TwitterHandle');
     }
 }
    function doUp()
    {
        global $database;
        if (DBSchema::existsColumn($database, 'Presentation', 'SummitID')) {
            $SQL = <<<SQL
 UPDATE Presentation SET SummitID = 5;
SQL;
            DB::query($SQL);
            DB::query('DELETE FROM SummitEvent;');
            $SQL = <<<SQL

INSERT INTO SummitEvent
(ID, Created, LastEdited, ClassName, Title, Description, SummitID)
SELECT ID, Created, LastEdited, ClassName, Title, Description, SummitID FROM Presentation;
SQL;
            DB::query($SQL);
            $SQL = <<<SQL
ALTER TABLE Presentation
  DROP COLUMN Title,
  DROP COLUMN SummitID,
  DROP COLUMN Description;
SQL;
            DB::query($SQL);
            $SQL = <<<SQL
INSERT INTO SummitAbstractLocation
(ID, ClassName, Created, LastEdited, `Name`, Description, `Order`, SummitID, LocationType)
SELECT ID, 'SummitVenue', Created, LastEdited, `Name` , Description, `Order`,
CASE SummitLocationPageID
WHEN 2345 THEN 4
WHEN 2579 THEN 5
ELSE NULL
END AS SummitID,
'Internal'
from SummitLocation where Type ='Venue';
SQL;
            DB::query($SQL);
            $SQL = <<<SQL
INSERT INTO SummitGeoLocatedLocation
(ID, Address1, WebSiteUrl, Lat, Lng, DisplayOnSite)
SELECT ID,Address, Website, Latitude, Longitude, DisplayOnSite
from SummitLocation where Type ='Venue';
SQL;
            DB::query($SQL);
            $SQL = <<<SQL
INSERT INTO SummitAbstractLocation
(ID, ClassName, Created, LastEdited, `Name`, Description, `Order`, SummitID, LocationType)
SELECT ID, 'SummitHotel', Created, LastEdited, `Name` , Description, `Order`,
CASE SummitLocationPageID
WHEN 2345 THEN 4
WHEN 2579 THEN 5
ELSE 0
END AS SummitID,
'External'
from SummitLocation where Type ='Hotel';
SQL;
            DB::query($SQL);
            $SQL = <<<SQL
INSERT INTO SummitGeoLocatedLocation
(ID, Address1, WebSiteUrl, Lat, Lng, DisplayOnSite)
SELECT ID,Address, Website, Latitude, Longitude, DisplayOnSite
from SummitLocation where Type ='Hotel';
SQL;
            DB::query($SQL);
            $SQL = <<<SQL
INSERT INTO SummitHotel
(ID, BookingLink, SoldOut)
SELECT ID,BookingLink, IsSoldOut
from SummitLocation where Type ='Hotel';
SQL;
            DB::query($SQL);
            $SQL = <<<SQL
INSERT INTO SummitAbstractLocation
(ID, ClassName, Created, LastEdited, `Name`, Description, `Order`, SummitID, LocationType)
SELECT ID, 'SummitAirport', Created, LastEdited, `Name` , Description, `Order`,
CASE SummitLocationPageID
WHEN 2345 THEN 4
WHEN 2579 THEN 5
ELSE 0
END AS SummitID,
'External'
from SummitLocation where Type ='Airport';
SQL;
            DB::query($SQL);
            $SQL = <<<SQL
INSERT INTO SummitGeoLocatedLocation
(ID, Address1, WebSiteUrl, Lat, Lng, DisplayOnSite)
SELECT ID,Address, Website, Latitude, Longitude, DisplayOnSite
from SummitLocation where Type ='Airport';
SQL;
            DB::query($SQL);
            $SQL = <<<SQL
INSERT INTO
SummitAirport
(ID)
SELECT ID from SummitLocation where Type ='Airport';
SQL;
            DB::query($SQL);
        }
    }