mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-03-12 20:18:02 -04:00
* `execute_script()` now returns a boolean for error handling. * Added transaction to `Migration_MissingConfigKeys.up()`. * Added logging to various migrations. * Added transaction to `Migration_MissingConfigKeys.up()`. * Added logging to various migrations. * Formatting and function call fixes Fixed a minor formatting issue in the migration helper. Replaced a few remaining error_log() calls. Updated executeScriptWithTransaction() to use log_message() * Function call fix Replaced the last error_log() calls with log_message(). --------- Co-authored-by: Joe Williams <hey-there-joe@outlook.com>
33 lines
1.2 KiB
PHP
33 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
use App\Models\Attribute;
|
|
use CodeIgniter\Database\ResultInterface;
|
|
|
|
class Migration_Attributes_fix_cascading_delete extends Migration
|
|
{
|
|
/**
|
|
* Perform a migration step.
|
|
*/
|
|
public function up(): void
|
|
{
|
|
log_message('info', 'Fixing cascading deletes.');
|
|
helper('migration');
|
|
|
|
$this->db->query("ALTER TABLE `ospos_attribute_links` DROP INDEX `attribute_links_uq3`");
|
|
$this->db->query("ALTER TABLE `ospos_attribute_links` DROP COLUMN `generated_unique_column`");
|
|
|
|
dropForeignKeyConstraints(['ospos_attribute_links_ibfk_1', 'ospos_attribute_links_ibfk_2'], 'attribute_links');
|
|
|
|
$this->db->query("ALTER TABLE `ospos_attribute_links` ADD CONSTRAINT `ospos_attribute_links_ibfk_1` FOREIGN KEY (`definition_id`) REFERENCES `ospos_attribute_definitions` (`definition_id`) ON DELETE CASCADE;");
|
|
$this->db->query("ALTER TABLE `ospos_attribute_links` ADD CONSTRAINT `ospos_attribute_links_ibfk_2` FOREIGN KEY (`attribute_id`) REFERENCES `ospos_attribute_values` (`attribute_id`) ON DELETE CASCADE;");
|
|
}
|
|
|
|
/**
|
|
* Revert a migration step.
|
|
*/
|
|
public function down(): void {}
|
|
}
|