Feat: books published

This commit is contained in:
Sallu9007
2025-03-31 22:57:21 +05:30
parent b2060c47e2
commit 2aa0cf0449
11 changed files with 853 additions and 61 deletions

View File

@@ -0,0 +1,48 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('books_published', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('department_id');
$table->unsignedBigInteger('faculty_id'); // Faculty who uploaded the publication
$table->text('author');
$table->string('title');
$table->string('publisher');
$table->string('issn', 9)->nullable();
$table->date('date_of_publication');
$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();
});
// Add ISSN format check constraint manually
DB::statement("ALTER TABLE books_published ADD CONSTRAINT chk_issn_format CHECK (issn REGEXP '^[0-9]{4}-[0-9]{3}[0-9X]$')");
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('books_published');
}
};