0

(I'm french, I hope you will understand my request ^^).

I'm very new on Laravel ! I am making a Laravel app and i've install the Breeze extension to manage connexion.

But now I want to include some Table from my dataBase and I don't want to migrate EVERYTABLE : only certain. How Can I migrate only wanted table (1 or more) ? It the good way to do it ? Should I build the model myself ? I don't want to modify the existing user table

I've search on internet but I only find way to make a full migration. And I don't want to destroy the Breeze scafolding.

  • Does this answer your question? [Running one specific Laravel migration (single file)](https://stackoverflow.com/questions/19102197/running-one-specific-laravel-migration-single-file) – timgavin Apr 23 '23 at 00:24
  • No : I want to create a Model from my DataBase, but only one Model. Not a migration ^^ – DeveCout Apr 23 '23 at 11:08

1 Answers1

0

I understand you already have a users table and you don't want to use the breeze users table (I would recommend not to do that). When you install breeze it creates the user model for you. There you can specify the table the model should use like this:

<?php
 
namespace App\Models;
 
use Illuminate\Database\Eloquent\Model;
 
class Flight extends Model
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'my_flights';
}

You can then mark your users migration: Mark migration as run in laravel

And then run the other migrations breeze generates for you

Esteban
  • 1
  • 1
  • 1
  • So If understand it well : I will make a migration to create my Model (in your exemple "Flight"). And after that my Model User will be destroyed/Modified ? So I have to run the Breeze Migration to retrieve the User Model ? Thanks for your help btw ;) – DeveCout Apr 23 '23 at 11:08
  • No. When you create a new project, laravel creates the user migration and the user model. as you don't want to run the users migration because you already have an users table, you have to specify the table's name in the model and that's enough for the model to use that existing table. after that, if you execute php artisan migrate:status you will see your users table as not migrated, it may cause you problems later when you try to run other migrations, so you should mark it as migrated as the post a linked says. – Esteban Apr 23 '23 at 14:35
  • Also, breeze might have generated other migrations for you depending on the features you required (like password reset or email verification), so you should run those migrations too in case you have those pending migrations. – Esteban Apr 23 '23 at 14:38