75 lines
2.2 KiB
PHP
75 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
class CreatePrintRequests extends Migration
|
|
{
|
|
public function up()
|
|
{
|
|
$this->forge->addField([
|
|
'id' => [
|
|
'type' => 'INT',
|
|
'constraint' => 11,
|
|
'unsigned' => true,
|
|
'auto_increment' => true,
|
|
],
|
|
'teacher_id' => [
|
|
'type' => 'INT',
|
|
'constraint' => 11,
|
|
'unsigned' => true,
|
|
],
|
|
'admin_id' => [
|
|
'type' => 'INT',
|
|
'constraint' => 11,
|
|
'unsigned' => true,
|
|
'null' => true,
|
|
],
|
|
'class_id' => [
|
|
'type' => 'INT',
|
|
'constraint' => 11,
|
|
'unsigned' => true,
|
|
],
|
|
'file_path' => [
|
|
'type' => 'VARCHAR',
|
|
'constraint' => '255',
|
|
],
|
|
'num_copies' => [
|
|
'type' => 'INT',
|
|
'constraint' => 11,
|
|
],
|
|
'required_by' => [
|
|
'type' => 'DATETIME',
|
|
],
|
|
'pickup_method' => [
|
|
'type' => 'VARCHAR',
|
|
'constraint' => '255',
|
|
],
|
|
'status' => [
|
|
'type' => 'ENUM',
|
|
'constraint' => ['not_assigned', 'assigned', 'done', 'delivered'],
|
|
'default' => 'not_assigned',
|
|
],
|
|
'created_at' => [
|
|
'type' => 'DATETIME',
|
|
'null' => true,
|
|
],
|
|
'updated_at' => [
|
|
'type' => 'DATETIME',
|
|
'null' => true,
|
|
],
|
|
]);
|
|
$this->forge->addKey('id', true);
|
|
$this->forge->addForeignKey('teacher_id', 'users', 'id', 'CASCADE', 'CASCADE');
|
|
$this->forge->addForeignKey('admin_id', 'users', 'id', 'CASCADE', 'SET NULL');
|
|
$this->forge->addForeignKey('class_id', 'classes', 'id', 'CASCADE', 'CASCADE');
|
|
$this->forge->createTable('print_requests');
|
|
}
|
|
|
|
public function down()
|
|
{
|
|
$this->forge->dropTable('print_requests');
|
|
}
|
|
}
|