Skip to content

Commit

Permalink
[TM-675] Fix up the migration after some testing with a fresh clone o…
Browse files Browse the repository at this point in the history
…f prod.
  • Loading branch information
roguenet committed May 15, 2024
1 parent aa95131 commit f733c5f
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
public function up(): void
{
DB::table('v2_sites')
->where('old_model', 'App\Models\Terrafund\TerrafundSite')
->whereNot('framework_key', 'ppc')
->update(['old_id' => null]);
DB::table('v2_projects')
->where('old_model', 'App\Models\Terrafund\TerrafundProgramme')
->whereNot('framework_key', 'ppc')
->update(['old_id' => null]);

Schema::table('v2_sites', function (Blueprint $table) {
Expand All @@ -30,7 +30,7 @@ public function up(): void
CREATE TRIGGER before_insert_v2_sites BEFORE INSERT ON v2_sites
FOR EACH ROW
BEGIN
IF (NEW.framework_key = \'ppc\') THEN
IF (NEW.framework_key = \'ppc\' and NEW.ppc_external_id IS NULL) THEN
SET NEW.ppc_external_id = (SELECT max(ppc_external_id) + 1 FROM v2_sites);
END IF;
END;
Expand Down Expand Up @@ -58,7 +58,7 @@ public function up(): void
CREATE TRIGGER before_insert_v2_projects BEFORE INSERT ON v2_projects
FOR EACH ROW
BEGIN
IF (NEW.framework_key = \'ppc\') THEN
IF (NEW.framework_key = \'ppc\' and NEW.ppc_external_id IS NULL) THEN
SET NEW.ppc_external_id = (SELECT max(ppc_external_id) + 1 FROM v2_projects);
END IF;
END;
Expand Down

0 comments on commit f733c5f

Please sign in to comment.