phplaravelartisan-migrate

Laravel not creating migration table for existing model


I generated a model using this command:

php artisan make:model Notification

the model file looks like this :

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * App\Models\Notification
 *
 * @property int $id
 * @property int|null $address_id
 * @property string $business_name
 * @property string $legal_structure
 * @property string|null $siret_number
 * @property string|null $rna_number
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @mixin \Eloquent
 */
class Notification extends Model
{
    /**
     * The attributes that aren't mass assignable.
     *
     * @var array
     */
    protected $guarded = ['id'];
    
}

then I used the make migration command to create the model's table in the database but it returns nothing to migrate and it doesn't create any table


Solution

  • If your application uses Laravel's built in notifications, then you already have a notifications table and migration created from running php artisan notifications:table.

    Laravel won't create another migration file for the table if one already exists.

    You will need to use a different table name, and I would suggest renaming your Notification model to match whatever table name you choose.