Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Add missing down method
  • Loading branch information
caleeli committed Jun 12, 2024
commit c90dd090b87b9e97e132e65ba6a6673d1592bc6f
22 changes: 21 additions & 1 deletion upgrades/2024_06_12_150527_create_nayra_script_executor.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?php

use Illuminate\Support\Facades\Log;
use ProcessMaker\Models\Script;
use ProcessMaker\Models\ScriptExecutor;
use ProcessMaker\ScriptRunners\Base;
use ProcessMaker\Upgrades\UpgradeMigration as Upgrade;

class CreateNayraScriptExecutor extends Upgrade
{

/**
* Run the upgrade migration.
*
Expand All @@ -22,4 +23,23 @@ public function up()
$scriptExecutor->save();
}
}

/**
* Reverse the upgrade migration.
*
* @return void
*/
public function down()
{
try {
$existsScriptsUsingNayra = Script::where('language', Base::NAYRA_LANG)->exists();
if (!$existsScriptsUsingNayra) {
ScriptExecutor::where('language', Base::NAYRA_LANG)->delete();
} else {
Log::error('There are scripts using Nayra, so the Nayra script executor cannot be deleted.');
}
} catch (Exception $e) {
Log::error('Cannot delete Nayra script executor: ' . $e->getMessage());
}
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing "down" method

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing method was added