Files
alrahma_sunday_school/app/Database/Migrations/2026-09-01-000100_CreateJobPostings.php
root 9e2f858343
Deploy to Shared Hosting / Shared hosting deploy (push) Failing after 48s
Tests / PHPUnit (push) Successful in 1m22s
fix job positions
2026-09-03 13:01:36 -04:00

104 lines
5.8 KiB
PHP

<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateJobPostings extends Migration
{
public function up()
{
if (!$this->db->tableExists('job_templates')) {
$this->forge->addField([
'template_id' => ['type' => 'VARCHAR', 'constraint' => 36],
'title' => ['type' => 'VARCHAR', 'constraint' => 255],
'description' => ['type' => 'TEXT', 'null' => true],
'department' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'location' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'employment_type' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
'responsibilities' => ['type' => 'TEXT', 'null' => true],
'requirements' => ['type' => 'TEXT', 'null' => true],
'version' => ['type' => 'INT', 'constraint' => 11, 'default' => 1],
'is_active' => ['type' => 'TINYINT', 'constraint' => 1, 'default' => 1],
'created_by' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'null' => true],
'created_at' => ['type' => 'DATETIME', 'null' => true],
'updated_at' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addKey('template_id', true);
$this->forge->addKey('is_active', false, false, 'idx_job_templates_active');
$this->forge->createTable('job_templates', true);
}
if (!$this->db->tableExists('job_template_versions')) {
$this->forge->addField([
'version_id' => ['type' => 'VARCHAR', 'constraint' => 36],
'template_id' => ['type' => 'VARCHAR', 'constraint' => 36],
'version' => ['type' => 'INT', 'constraint' => 11],
'title' => ['type' => 'VARCHAR', 'constraint' => 255],
'description' => ['type' => 'TEXT', 'null' => true],
'department' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'location' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'employment_type' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
'responsibilities' => ['type' => 'TEXT', 'null' => true],
'requirements' => ['type' => 'TEXT', 'null' => true],
'saved_by' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'null' => true],
'saved_at' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addKey('version_id', true);
$this->forge->addKey('template_id', false, false, 'idx_template_versions_template_id');
$this->forge->createTable('job_template_versions', true);
}
if (!$this->db->tableExists('job_positions')) {
$this->forge->addField([
'position_id' => ['type' => 'VARCHAR', 'constraint' => 36],
'template_id' => ['type' => 'VARCHAR', 'constraint' => 36, 'null' => true],
'title' => ['type' => 'VARCHAR', 'constraint' => 255],
'description' => ['type' => 'TEXT', 'null' => true],
'department' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'location' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'employment_type' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
'responsibilities' => ['type' => 'TEXT', 'null' => true],
'requirements' => ['type' => 'TEXT', 'null' => true],
'status' => ['type' => 'VARCHAR', 'constraint' => 20, 'default' => 'draft'],
'posted_by' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'null' => true],
'posted_at' => ['type' => 'DATETIME', 'null' => true],
'details_click_count' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'default' => 0],
'created_at' => ['type' => 'DATETIME', 'null' => true],
'updated_at' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addKey('position_id', true);
$this->forge->addKey('status', false, false, 'idx_job_positions_status');
$this->forge->createTable('job_positions', true);
}
if (!$this->db->tableExists('applications')) {
$this->forge->addField([
'application_id' => ['type' => 'VARCHAR', 'constraint' => 36],
'position_id' => ['type' => 'VARCHAR', 'constraint' => 36],
'first_name' => ['type' => 'VARCHAR', 'constraint' => 100],
'last_name' => ['type' => 'VARCHAR', 'constraint' => 100],
'email' => ['type' => 'VARCHAR', 'constraint' => 255],
'phone' => ['type' => 'VARCHAR', 'constraint' => 30],
'resume_file_url' => ['type' => 'TEXT'],
'status' => ['type' => 'VARCHAR', 'constraint' => 20, 'default' => 'new'],
'admin_notes' => ['type' => 'TEXT', 'null' => true],
'submitted_at' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addKey('application_id', true);
$this->forge->addKey('position_id', false, false, 'idx_applications_position_id');
$this->forge->addKey('status', false, false, 'idx_applications_status');
$this->forge->addKey('email', false, false, 'idx_applications_email');
$this->forge->createTable('applications', true);
}
}
public function down()
{
$this->forge->dropTable('applications', true);
$this->forge->dropTable('job_positions', true);
$this->forge->dropTable('job_template_versions', true);
$this->forge->dropTable('job_templates', true);
}
}