mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-09-20 17:57:12 -04:00
feat(jobs): add jobs module with throttling and config keys
- Register jobs module, permission, and admin grant so it appears in menu/ACL (20260916000000_AddJobsModule.php) - Add job_throttles table to support rate-limiting job runs (20260916000001_CreateJobThrottles.php) - Seed app_config with jobs_mode and jobs_web_max_seconds defaults for web-based job execution (20260916000002_AddJobsConfigKeys.php) - Drop redundant FK re-add in fix_keys_for_db_upgrade migration that duplicated an already-existing constraint Signed-off-by: objecttothis <17935339+objecttothis@users.noreply.github.com>
This commit is contained in:
1 parent
f2b73fda36
commit
8e6032a285
4 files changed
+91
-4
No files matched your search
@@ -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)');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AddJobsModule extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
$this->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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class CreateJobThrottles extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
$this->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');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AddJobsConfigKeys extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
$jobsConfigValues = [
|
||||
['key' => '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();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user