diff --git a/app/Database/Migrations/20240630000001_fix_keys_for_db_upgrade.php b/app/Database/Migrations/20240630000001_fix_keys_for_db_upgrade.php index 2ee75cc7f..2e9007781 100644 --- a/app/Database/Migrations/20240630000001_fix_keys_for_db_upgrade.php +++ b/app/Database/Migrations/20240630000001_fix_keys_for_db_upgrade.php @@ -58,9 +58,5 @@ class Migration_fix_keys_for_db_upgrade extends Migration if ($foreignKeyExists) { $this->db->query('ALTER TABLE ' . $this->db->prefixTable('sales_items_taxes') . ' DROP FOREIGN KEY ospos_sales_items_taxes_ibfk_1'); } - - $this->db->query('ALTER TABLE ' . $this->db->prefixTable('sales_items_taxes') - . ' ADD CONSTRAINT ospos_sales_items_taxes_ibfk_1 FOREIGN KEY (sale_id) ' - . ' REFERENCES ' . $this->db->prefixTable('sales_items') . ' (sale_id)'); } } diff --git a/app/Database/Migrations/20260916000000_AddJobsModule.php b/app/Database/Migrations/20260916000000_AddJobsModule.php new file mode 100644 index 000000000..981f7d73f --- /dev/null +++ b/app/Database/Migrations/20260916000000_AddJobsModule.php @@ -0,0 +1,36 @@ +db->table('modules')->insert([ + 'module_id' => 'jobs', + 'name_lang_key' => 'jobs', + 'desc_lang_key' => 'jobs_desc', + 'sort' => 130, + ]); + + $this->db->table('permissions')->insert([ + 'permission_id' => 'jobs', + 'module_id' => 'jobs', + ]); + + $this->db->table('grants')->insert([ + 'permission_id' => 'jobs', + 'person_id' => 1, + 'menu_group' => 'office', + ]); + } + + public function down(): void + { + $this->db->table('grants')->where('permission_id', 'jobs')->delete(); + $this->db->table('permissions')->where('permission_id', 'jobs')->delete(); + $this->db->table('modules')->where('module_id', 'jobs')->delete(); + } +} diff --git a/app/Database/Migrations/20260916000001_CreateJobThrottles.php b/app/Database/Migrations/20260916000001_CreateJobThrottles.php new file mode 100644 index 000000000..a12a5cb43 --- /dev/null +++ b/app/Database/Migrations/20260916000001_CreateJobThrottles.php @@ -0,0 +1,25 @@ +forge->addField([ + 'throttle_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true], + 'max_count' => ['type' => 'INT', 'unsigned' => true, 'default' => 0], + 'period' => ['type' => 'ENUM', 'constraint' => ['minute', 'hour', 'day', 'month']], + 'deleted' => ['type' => 'TINYINT', 'constraint' => 1, 'default' => 0], + ]); + $this->forge->addPrimaryKey('throttle_id'); + $this->forge->createTable('job_throttles'); + } + + public function down(): void + { + $this->forge->dropTable('job_throttles'); + } +} diff --git a/app/Database/Migrations/20260916000002_AddJobsConfigKeys.php b/app/Database/Migrations/20260916000002_AddJobsConfigKeys.php new file mode 100644 index 000000000..3666bf859 --- /dev/null +++ b/app/Database/Migrations/20260916000002_AddJobsConfigKeys.php @@ -0,0 +1,30 @@ + 'jobs_mode', 'value' => 'web'], + ['key' => 'jobs_web_max_seconds', 'value' => '5'], + ]; + + $this->db->table('app_config')->ignore(true)->insertBatch($jobsConfigValues); + } + + public function down(): void + { + $jobsConfigKeys = [ + 'jobs_mode', + 'jobs_web_max_seconds', + ]; + + $this->db->table('app_config') + ->whereIn('key', $jobsConfigKeys) + ->delete(); + } +}