ARTICLE AD BOX
Here's my laravel composer.json for its version info:
{ "name": "laravel/laravel", "type": "project", "description": "The skeleton application for the Laravel framework.", "keywords": [ "laravel", "framework" ], "license": "MIT", "require": { "php": "^8.1", "guzzlehttp/guzzle": "^7.2", "laravel/framework": "^10.0", "laravel/sanctum": "^3.3", "laravel/tinker": "^2.8", "laravel/ui": "^4.6" }, "require-dev": { "fakerphp/faker": "^1.9.1", "laravel/pint": "^1.0", "laravel/sail": "^1.18", "mockery/mockery": "^1.4.4", "nunomaduro/collision": "^7.0", "phpunit/phpunit": "^10.1", "spatie/laravel-ignition": "^2.0" }, "autoload": { "psr-4": { "App\\": "app/", "Database\\Factories\\": "database/factories/", "Database\\Seeders\\": "database/seeders/" } }, "autoload-dev": { "psr-4": { "Tests\\": "tests/" } }, "scripts": { "post-autoload-dump": [ "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", "@php artisan package:discover --ansi" ], "post-update-cmd": [ "@php artisan vendor:publish --tag=laravel-assets --ansi --force" ], "post-root-package-install": [ "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" ], "post-create-project-cmd": [ "@php artisan key:generate --ansi" ] }, "extra": { "laravel": { "dont-discover": [] } }, "config": { "optimize-autoloader": true, "preferred-install": "dist", "sort-packages": true, "allow-plugins": { "pestphp/pest-plugin": true, "php-http/discovery": true } }, "minimum-stability": "stable", "prefer-stable": true }My Student migration:
<?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('students', function (Blueprint $table) { $table->id(); $table->unsignedBigInteger('identification_number')->unique(); $table->string('name'); $table->integer('class_level', 3); $table->string('major'); $table->timestamps(); }); } /** * Reverse the migrations. */ public function down(): void { Schema::dropIfExists('students'); } };My Student model:
<?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use App\Enums\MajorEnums; class Students extends Model { use HasFactory; protected $fillable = ['identification_number', 'name', 'class_level', 'major']; protected $casts = [ 'major' => MajorEnums::class ]; public function AspirationReports() { return $this->hasMany(AspirationReports::class); } }Error log:
(base) evanfersadi@pop-os:~/Dokumen/School/pengaduan$ php artisan migrate:fresh Dropping all tables ........................................................................................................ 27ms DONE INFO Preparing database. Creating migration table .................................................................................................... 4ms DONE INFO Running migrations. 2014_10_12_000000_create_users_table ........................................................................................ 7ms DONE 2014_10_12_100000_create_password_reset_tokens_table ........................................................................ 4ms DONE 2014_10_12_100000_create_password_resets_table .............................................................................. 3ms DONE 2019_08_19_000000_create_failed_jobs_table .................................................................................. 8ms DONE 2019_12_14_000001_create_personal_access_tokens_table ....................................................................... 5ms DONE 2025_11_24_064503_create_students_table ..................................................................................... 1ms FAIL Illuminate\Database\QueryException SQLSTATE[42P16]: Invalid table definition: 7 ERROR: multiple primary keys for table "students" are not allowed at character 164 (Connection: pgsql, SQL: create table "students" ("id" bigserial not null primary key, "identification_number" bigint not null, "name" varchar(255) not null, "class_level" serial not null primary key, "major" varchar(255) not null, "created_at" timestamp(0) without time zone null, "updated_at" timestamp(0) without time zone null)) at vendor/laravel/framework/src/Illuminate/Database/Connection.php:829 825▕ $this->getName(), $query, $this->prepareBindings($bindings), $e 826▕ ); 827▕ } 828▕ ➜ 829▕ throw new QueryException( 830▕ $this->getName(), $query, $this->prepareBindings($bindings), $e 831▕ ); 832▕ } 833▕ } +9 vendor frames 10 database/migrations/2025_11_24_064503_create_students_table.php:21 Illuminate\Support\Facades\Facade::__callStatic() +36 vendor frames 47 artisan:37 Illuminate\Foundation\Console\Kernel::handle()