This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

Autumn
Autumn

Hello i tryed to create simple plugin with database. php artisan create:plugin Foo.Bar php artisan create:model Foo.Bar Post

and update migration file, but how can i create table from migration?

php artisan plugin:refresh Foo.Bar and nothing happend (table not exists in database), what wrong ?

php artisan plugin:refresh Foo.Bar Rolled back: Foo.Bar
Reinstalling plugin...
Foo.Bar

  • Nothing to update.

class CreatePostsTable extends Migration {

public function up()
{
    Schema::create('foo_bar_posts', function($table)
    {
        $table->engine = 'InnoDB';
        $table->increments('id');
        $table->integer('user_id')->unsigned()->nullable()->index();
        $table->string('title')->nullable();
        $table->string('slug')->index();
        $table->text('content')->nullable();
        $table->text('content_html');
        $table->timestamp('published_at')->nullable();
        $table->boolean('published')->default(false);
    });
}

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

}

jekinney
jekinney

Where do you have the Migration file located? Should have a file named updates with another file named seed_all_tables that will run all the migration files you require.

Autumn
Autumn

ok jekinney, i create also seed_all_tables with empty up() method and run artisan october:up and artisan plugin:refresh Foo.Bar and table in database couldn't create what wrong? What secret are here? (

Autumn
Autumn

i've updated version.yaml and copy from blog some strings

  0.0.1:
   - Initialize plugin
   - create_post_table.php
   - seed_all_tables.php

and run commands from docu, and from plugin list my plugis has been removed ( wtf ? ) and tables doesn't created

Last updated

Autumn
Autumn

PS i hate markdown, return bb codes

bestxp
bestxp

For solve this problem i've deleted plugin and create again

benfreke
benfreke

I had a similar problem. The version number had to be greater than 1 for it to work for me. i.e. version number 1.0.1, with - seed_all_tables.php and the class called SeedAllTables.

HTH

Tiipiik
Tiipiik

Hi there, I should be stupid, I'm trying to make some Test plugin but cannot have Artisan to find him on artisan plugin:install Tiipiik.Test, it returns "plugin could not be find". What am I doing wrong ?

benfreke
benfreke

Hi @Tiipiik

pluging:install will only download official plugins. I assume you're trying to create one on your local install? If so, you need php artisan plugin:create Tiipiik.Test

Check out the available console commands, particularly plugin:refresh .

Tiipiik
Tiipiik

Thank you Benfreke, I was missing that page ! You're right I'm trying to create my own on local install ;)

planetadeleste
planetadeleste

I have the same problem creating my own plugin. After try many options, remove and create again the plugin, etc.

I found the problem, the command php artisan plugin:refresh does not make any migration if the environment is "production". I change the line return isset($_SERVER['CMS_ENV']) ? $_SERVER['CMS_ENV'] : 'production'; to return 'devel'; and work ok. This is on /bootstrap/start.php

Original October installation

$env = $app->detectEnvironment(function(){
    return isset($_SERVER['CMS_ENV']) ? $_SERVER['CMS_ENV'] : 'production';
});

Changed to this

$env = $app->detectEnvironment(function(){
    return 'devel';
});

Last updated

pboislard33288
pboislard33288

I have the same problem, and after try many option, you have to set your version.yaml exacly like the following:

1.0.2:

- Create blog post comments table  // create yourTablename table     //syntax is important!!
- create_comments_table.php    //name of the files to migrate

Last updated

jered.masters3609
jered.masters3609

Thank you pboislard! It took me along time to solve this and your answer helped a lot. I'm sure it was a combination of implementing the all the fixes listed above. This was a really annoying issue and should be more clearly documented.

nerijunior
nerijunior

pboislard33288 Thanks by the solution!

Last updated

sacwebdeveloper
sacwebdeveloper

Solved. At first glance, it seems you could type just about anything after the version number, but in actuality, the YAML parser parses your versions.yaml file for each script listed. I tried changing my version file to and it worked.

1.0.1: First version of MyPlugin
1.0.2:
    - Create MyPlugin Table
    - create_myplugin_table.php

To understand what it's doing, the class that defines this command is in

/modules/system/console/PluginRefresh.php

It actually goes sort of deep from there but it basically parses your YAML version.yaml file and compares it to what is in the database. In case you missed it, there is documentation on the version file.

http://octobercms.com/docs/database/structure#update-files

As stated in the documentation for script updates, the first line is a comment and subsequent lines are scripts to run. Also note, YAML lists do not allow tabs.

Last updated

keonovic
keonovic

I had the same problem, I finally discovered that my migration script was inside of an updates directory for the whole plugin, rather than for my component. I moved the migration script into the same updates directory as my version.yaml file and it ran correctly!

franata
franata

thanks @pboislard33288

alisovpv7678
alisovpv7678

when you try to create a plug-in command


$ php artisan create:plugin author.name

I get a message about the successful creation of the plugin. But is not that the directory structure as described in the documentation:

 
author/name/Plugin.php 

and this type of


author/name/author/name/Plugin.php 

backend and create a plugin that is not displayed. What could be the reason for the construction of catalogs?

sorry for my english = (

Last updated

alisovpv7678
sanvatvungcao.com17714
sanvatvungcao.com17714

The problem is solved. You must update version.yaml:

  • Description version here
  • create_invsubscribers_table.php // It name of file on: plugins/author/pluginname/updates/create_invsubscribers_table.php

Hope it useful for you.

1-20 of 22

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.