48 lines
1.4 KiB
PHP
48 lines
1.4 KiB
PHP
<?php
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
return new class extends Migration
|
|
{
|
|
/**
|
|
* Run the migrations.
|
|
*/
|
|
public function up(): void
|
|
{
|
|
Schema::create('patents', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->unsignedBigInteger('department_id');
|
|
$table->unsignedBigInteger('faculty_id'); // Faculty who uploaded the publication
|
|
|
|
$table->string('title');
|
|
$table->string('investigator');
|
|
$table->string('application_no');
|
|
$table->string('type');
|
|
$table->date('date_of_submission');
|
|
$table->date('date_of_filling');
|
|
$table->string('status');
|
|
$table->string('proof')->nullable(); // For file path
|
|
|
|
// Foreign keys
|
|
$table->foreign('department_id')->references('id')->on('departments')->onDelete('cascade');
|
|
$table->foreign('faculty_id')->references('id')->on('users')->onDelete('cascade');
|
|
|
|
// Indexes for better performance
|
|
$table->index('department_id');
|
|
$table->index('faculty_id');
|
|
|
|
$table->timestamps();
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*/
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('patents');
|
|
}
|
|
};
|