ivandoric / Making-Websites-With-October-CMS

This is a repository for video tutorial series about making websites with October CMS. You can check out the series here: https://goo.gl/eW32CM
160 stars 52 forks source link

Adding new fields to extended user's plugin #34

Open os-kingsley opened 5 years ago

os-kingsley commented 5 years ago

I extended the user's plugin going by the tutorial and it works ok. Now i want to add new fields using the same plugin i created for the extension by adding this as an additional file in the updates folder

<?php namespace Corymillz\Store\Updates;

use Schema;
use October\Rain\Database\Updates\Migration;

class AddNewFeilds extends Migration
{

    public function up()
    {
        Schema::table('users', function($table)
        {

            $table->string('store_title_font')->nullable();
             $table->string('store_title_font_color')->nullable();
            $table->string('store_description_font')->nullable();
            $table->string('store_description_font_color')->nullable();
            $table->string('background_size')->nullable();

        });
    }

    public function down()
{
    Schema::table('users', function($table) {
        $table->dropColumn([
            'store_title_font',
            'store_title_font_color',
            'store_description_font',
            'store_description_font_color',
            'background_size',

        ]);
    });
} 

}

What i am not clear about or scared to try is what happens when i run php artisan plugin:refresh. Will the first table be dropped and rebuilt with the data saved in it deleted? or is there a different way of adding new fields to the already extended fields.