dimanche 29 octobre 2017

Laravel - refactor table names (migration) will Models/Controllers go with it?

I would like to rename a table in the database from topics to galleries and I have created a migration that will rename my table. Schema::rename('foo', 'bar');

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class RenameTopicsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        //
        Schema::rename('topics', 'galleries');
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
        Schema::rename('galleries', 'topics');
    }
}

However will the Topic Model and Topic Controller be automatically renamed? Or will I have to refactor my code? Does Laravel provide a way to do this easily?

In short my question is - How do you change your schema easily in laravel? (models/controllers/database/requests/transformers ect..)

Thanks!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire