laraveloctobercmsoctobercms-pluginsoctobercms-backend

Creating new table in octobercms


I must create new table in octobercms project and I followed documentation and added new migration file inside plugin update file I have create_currency_rates_table.php file and it has this codes

<?php namespace RainLab\User\Updates;
use Schema;
use October\Rain\Database\Updates\Migration;

class CreateCurrencyRateTable extends Migration
{
    public function up()
    {
        Schema::create('currency_rates', function($table)
        {
            $table->engine = 'InnoDB';
            $table->increments('id');
            $table->string('currency');
         
        });
    }

    public function down()
    {
        Schema::drop('currency_rate');
    }
}

when I used php artisan october:up it is not detecting new migration. How can I create new table?Can anyone help me?


Solution

  • You also need to update plugins\<author>\<plugin_name>\updates\version.yaml this file and add your file name there as well.

    So, in your case, you added a file like create_currency_rates_table.php then you need to add details of your file in version.yaml

    for ex:

    1.0.1: First version of Demo
    1.0.2:
      - Description About what is this update about?
      - create_currency_rates_table.php
    
    

    now when you next time just login to backend this table will be created automatically.

    if any doubt please comment.