Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TM-1594] remove tables #648

Open
wants to merge 17 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions app/Console/Commands/DeleteTerrafundProgrammeCommand.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use App\Models\Site as PPCSite;
use App\Models\Terrafund\TerrafundDueSubmission;
use App\Models\Terrafund\TerrafundNursery;
use App\Models\Terrafund\TerrafundProgramme;
use App\Models\Terrafund\TerrafundSite;
use App\Models\V2\Action;
use App\Models\V2\Nurseries\Nursery;
Expand Down Expand Up @@ -55,24 +54,6 @@ private function handleTerrafundStubs()
TerrafundDueSubmission::where('is_submitted', 0)->chunk(500, function ($chunk) use (&$count, &$created) {
foreach ($chunk as $stub) {
switch($stub->terrafund_due_submissionable_type) {
case TerrafundProgramme::class:
$project = Project::where('old_model', TerrafundProgramme::class)
->where('old_id', $stub->terrafund_due_submissionable_id)
->first();

if (! empty($project)) {
$report = ProjectReport::updateOrCreate([
'framework_key' => 'terrafund',
'project_id' => $project->id,
'status' => ReportStatusStateMachine::DUE,
'due_at' => $stub->due_at,
], []);

$this->handleTask($project, $stub);
$this->handleActions($project, $report);
}

break;
case TerrafundSite::class:
$site = Site::where('old_model', TerrafundSite::class)
->where('old_id', $stub->terrafund_due_submissionable_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
use App\Models\Terrafund\TerrafundFile;
use App\Models\Terrafund\TerrafundNursery;
use App\Models\Terrafund\TerrafundNurserySubmission;
use App\Models\Terrafund\TerrafundProgramme;
use App\Models\Terrafund\TerrafundProgrammeSubmission;
use App\Models\Terrafund\TerrafundSite;
use App\Models\Terrafund\TerrafundSiteSubmission;
use App\Models\V2\Nurseries\Nursery;
use App\Models\V2\Nurseries\NurseryReport;
use App\Models\V2\Projects\Project;
use App\Models\V2\Projects\ProjectReport;
use App\Models\V2\Sites\Site;
use App\Models\V2\Sites\SiteReport;
Expand Down Expand Up @@ -44,11 +42,6 @@ public function handle()
$this->info('Starting migration of terrafund file ' . $terrafundFile->id);

switch ($terrafundFile->fileable_type) {
case TerrafundProgramme::class:
$model = 'project';
$query = Project::query();

break;
case TerrafundSite::class:
$model = 'site';
$query = Site::query();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
namespace App\Console\Commands\Migration;

use App\Models\Terrafund\TerrafundNursery;
use App\Models\Terrafund\TerrafundProgramme;
use App\Models\V2\Nurseries\Nursery;
use App\Models\V2\Projects\Project;
use App\StateMachines\EntityStatusStateMachine;
use Illuminate\Console\Command;

Expand Down Expand Up @@ -71,14 +69,6 @@ private function mapValues(TerrafundNursery $nursery): array
'type' => data_get($nursery, 'nursery_type'),
];

$project = Project::where('old_model', TerrafundProgramme::class)
->where('old_id', $nursery->terrafund_programme_id)
->first();

if (! empty($project)) {
$data['project_id'] = $project->id;
}

return $data;
}
}
63 changes: 31 additions & 32 deletions app/Console/Commands/Migration/ProjectInvitesMigrationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Console\Commands\Migration;

use App\Models\Programme;
use App\Models\Terrafund\TerrafundProgramme;
use App\Models\V2\Projects\Project;
use App\Models\V2\Projects\ProjectInvite;
use App\Models\V2\User;
Expand Down Expand Up @@ -58,37 +57,37 @@ public function handle()
}


$collection = DB::table('terrafund_programme_invites')->get();
foreach ($collection as $item) {
$count++;
$project = Project::where('old_id', $item->terrafund_programme_id)
->where('old_model', TerrafundProgramme::class)
->first();

if ($project) {
$user = User::where('email_address', $item->email_address)->first();
$count = 0;
if (! empty($user)) {
$count = DB::table('v2_project_users')->where('user_id', $user->id)
->where('project_id', $project->id)
->where('status', 'active')
->count();
}

$invite = ProjectInvite::create([
'project_id' => $project->id,
'email_address' => $item->email_address,
'token' => $item->token,
'accepted_at' => $count > 0 ? $item->created_at : null,
]);

$invite->created_at = $item->created_at;
$invite->updated_at = $item->updated_at;
$invite->save();

$created++;
}
}
// $collection = DB::table('terrafund_programme_invites')->get();
// foreach ($collection as $item) {
// $count++;
// $project = Project::where('old_id', $item->terrafund_programme_id)
// ->where('old_model', TerrafundProgramme::class)
// ->first();

// if ($project) {
// $user = User::where('email_address', $item->email_address)->first();
// $count = 0;
// if (! empty($user)) {
// $count = DB::table('v2_project_users')->where('user_id', $user->id)
// ->where('project_id', $project->id)
// ->where('status', 'active')
// ->count();
// }

// $invite = ProjectInvite::create([
// 'project_id' => $project->id,
// 'email_address' => $item->email_address,
// 'token' => $item->token,
// 'accepted_at' => $count > 0 ? $item->created_at : null,
// ]);

// $invite->created_at = $item->created_at;
// $invite->updated_at = $item->updated_at;
// $invite->save();

// $created++;
// }
// }

echo('Processed:' . $count . ', Created: ' . $created . chr(10));
echo('- - - Finished - - - ' . chr(10));
Expand Down

This file was deleted.

78 changes: 0 additions & 78 deletions app/Console/Commands/Migration/ProjectUsersMigrationCommand.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace App\Console\Commands\Migration;

use App\Models\Terrafund\TerrafundProgramme;
use App\Models\Terrafund\TerrafundProgrammeSubmission;
use App\Models\V2\Projects\Project;
use App\Models\V2\Projects\ProjectReport;
use App\StateMachines\ReportStatusStateMachine;
use Illuminate\Console\Command;
Expand Down Expand Up @@ -123,14 +121,6 @@ private function mapValues(TerrafundProgrammeSubmission $submission): array

];

$project = Project::where('old_model', TerrafundProgramme::class)
->where('old_id', $submission->terrafund_programme_id)
->first();

if (! empty($project)) {
$data['project_id'] = $project->id;
}

return $data;
}

Expand Down
Loading
Loading