コード例 #1
0
 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>";
 }
コード例 #2
0
 function doUp()
 {
     global $database;
     if (DBSchema::existsTable($database, "JobPage")) {
         $res = DB::query("SELECT * FROM JobPage;");
         foreach ($res as $record) {
             $new_job = new Job();
             $new_job->ID = (int) $record['ID'];
             $new_job->Title = $record['Title'];
             $new_job->Description = $record['Content'];
             $new_job->Created = $record['Created'];
             $new_job->LastEdited = $record['LastEdited'];
             $new_job->PostedDate = $record['JobPostedDate'];
             $new_job->ExpirationDate = $record['ExpirationDate'];
             // company name logic
             $company_name = $record['JobCompany'];
             $company = Company::get()->filter('Name', $company_name)->first();
             $new_job->CompanyID = is_null($company) ? 0 : $company->ID;
             if ($new_job->CompanyID == 0) {
                 $new_job->CompanyName = $company_name;
             }
             $new_job->MoreInfoLink = $record['JobMoreInfoLink'];
             $new_job->Location = $record['JobLocation'];
             $new_job->IsFoundationJob = $record['FoundationJob'];
             $new_job->IsActive = $record['Active'];
             $new_job->Instructions2Apply = $record['JobInstructions2Apply'];
             $new_job->LocationType = $record['LocationType'];
             $new_job->IsCOANeeded = 0;
             $new_job->TypeID = 0;
             //registration request
             $registration_request = JobRegistrationRequest::get()->filter('Title', $new_job->Title)->first();
             if (!is_null($registration_request)) {
                 $new_job->RegistrationRequestID = $registration_request->ID;
             }
             $new_job->write();
         }
         DBSchema::dropTable($database, "JobPage");
     }
 }