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

GeorgeFoto
GeorgeFoto

I follow the instructions

  • php artisan create:plugin Acme.Todo
  • php artisan create:model Acme.Todo Task -php artisan plugin:refresh Acme.Todo

But the table is not created in the database. What should I do?

Last updated

Anand Patel
Anand Patel

you need to specify database migration file name in version.yaml then you need to fire

php artisan plugin:refresh Acme.Todo

for more detail checkout http://octobercms.com/docs/plugin/registration#migrations-version-history

Last updated

Shapeless
Shapeless

can you explain more on this? I am having the same problem. How do you specify a migration file name in version.yaml?

ndcisiv
ndcisiv

Just like it says to in the link above: 1.0.1:

- First version
- create_tables.php
- seed_the_database.php
GeorgeFoto
GeorgeFoto

philip4658

Insert in the version.yaml

1.0.2 - Second Version - create_tasks_table.php

and will work...

Anand Patel
Anand Patel

@philip4658

yes sure, structure of version.yaml is like this

1.0.1:
    - First version (comment)
    - create_tables.php (create table script)
    - seed_the_database.php (seed table script)

you need to specify version number in this case its 1.0.1, then you need to specify comment means what you have done in this version of plugin, then if you want to create new tables or seed tables or any thing related to database you need to create files in updates folder and specify below the comment.

To apply plugin updates during development, log out of the back-end and sign in again. The plugin version history is applied when an administrator signs in to the back-end.

and if you fired command from console php artisan plugin:refresh Acme.Todo this will reinstall(uninstall and then again install) plugin, i.e all your previous data for this plugin will be lost, you will get fresh copy of plugin.

Shapeless
Shapeless

I guess are you only supposed to seed the database once? In the "mastering components" tutorial in resources, there is no "seeding_the_database.php" file when you run php artisan create:plugin Acme.ToDo

Anand Patel
Anand Patel

@philip4658

we can seed tables as per our need, seeding is always not required, seeding is required when you want/wish to insert initial records after creating tables, that`s why seeding is not there in that tutorials.

for example you are creating blog plugin, you have two tables posts and categories, and you initially you want there exist one category(for example category name is uncategorized) at time of installing plugin, you can seed categories table in version.yaml

check out this https://github.com/rainlab/blog-plugin/blob/master/updates/version.yaml#L5

Last updated

janedoe
janedoe

Anand Patel said:

@philip4658

yes sure, structure of version.yaml is like this

1.0.1:
   - First version (comment)
   - create_tables.php (create table script)
   - seed_the_database.php (seed table script)

you need to specify version number in this case its 1.0.1, then you need to specify comment means what you have done in this version of plugin, then if you want to create new tables or seed tables or any thing related to database you need to create files in updates folder and specify below the comment.

To apply plugin updates during development, log out of the back-end and sign in again. The plugin version history is applied when an administrator signs in to the back-end.

and if you fired command from console php artisan plugin:refresh Acme.Todo this will reinstall(uninstall and then again install) plugin, i.e all your previous data for this plugin will be lost, you will get fresh copy of plugin.

i just want to add field in the table and want to update but as i update my previous data reset and plugins get reinstall how to stop reinstalling plugin again if i made any changes in it

1-9 of 9

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