4

I'm new to October, and I came across an issue which I wasn't able to solve. When I create a plugin from the command line, and run plugin:refresh the tables in the database are not being created.

The version.yaml is correct as per documentation. Here are the contents of the files. Plugin/Mejlak/PropertyExtender/Updates/create_extras_table.php

<?php namespace Mejlak\Propertyextender\Updates;

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

class CreateExtrasTable extends Migration
{
    public function up()
    {
        Schema::create('mejlak_propertyextender_extras', function(Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->increments('id');
            $table->string('title');
            $table->timestamps();
        });
    }

    public function down()
    {
        Schema::dropIfExists('mejlak_propertyextender_extras');
    }
}

And here is the version.yaml

1.0.1: 
    - 'First version of propertyextender'
    - create_extras_table.php

Any help would be highly appreciated

  • Your directories are lowercase? for instance: `plugins/mejlak/propertyextender/updates/` – OsDev Nov 30 '17 at 00:55

4 Answers4

2

Change your version.yaml to:

1.0.1: First version of propertyextender
1.0.2: 
  - create tables
  - create_extras_table.php

I have no idea why commands do not work on first plugin version. And you also have to put - create tables before the list of create_tablename_table.php files.

Susana Santos
  • 312
  • 1
  • 6
  • 18
0

I guess as per @OsDev suggested there may be issue with directory names.

you give us path for update is

Plugin/Mejlak/PropertyExtender/Updates/create_extras_table.php

so in this case you can correct some folder names

I am not sure but all your folder name is starting with capital letters, in october cms all are written in small so your path should be

plugin/mejlak/propertyextender/updates/create_extras_table.php

and yes in namespace its correct so no need to change there

namespace Mejlak\Propertyextender\Updates

then give it a try, if still its not working please comment.

Hardik Satasiya
  • 9,547
  • 3
  • 22
  • 40
0

Can you confirm the plugin refresh command you have tried to run?

php artisan plugin:refresh Mejlak.Propertyextender

Edgars Ozolins
  • 298
  • 5
  • 11
-1

No need to create migration-file/table manually. With 'https://octobercms.com/plugin/rainlab-builder' you can create a fully functional plugin scaffold in a matter of minutes.

1) install the plugin 2) Go to Builder-> Create plugin-> create enter image description here 3) Add table from Database enter image description here 4) Save and Apply migration file enter image description here Your plugin has been created with a table now.

Tauhed
  • 109
  • 6