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

gtf21
gtf21

Backstory:

I was writing a plugin for a client, so that we could make use of some models. I had created the migrations (I'm used to these from Laravel), and so on using php artisan create:model etc..

Problem:

Nothing I did, however, would run the migrations, until I came across a post mentioning that you had to add it to the version.yaml file as follows:

1.0.2:
    - create_products_table.php

This is not explicitly stated in the documentation (and was a bit of a headache). Could I request a proper tutorial / workflow is documented on the docs site so that this stuff is clear for those who didn't develop October?

Last updated

Flynsarmy
Flynsarmy

Did you miss Plugins - Registration & Versions - Migrations and version history in the docs?

Last updated

gtf21
gtf21

Admittedly I skim read

The version.yaml file, called the Plugin version file, contains the version comments and refers to database scripts in the correct order.

but since Laravel has never needed you to actually reference migrations since it automatically finds them, I still think it could be more helpfully (and explicitly) put as a sort of workflow/use case.

Daniel81
Daniel81

Maybe this will be useful in the future, The Builder Idea, will hopefully take a lot of the mundane stuff out of building plugins. I took got stuck on this when first building plugins, not 100% sure why it's needed unless you're using the database, in which case you are, but a lot of plugins don't require DB access, so it's only needed for version purposes.

Maybe a $pluginVersion variable in the plugin.php would be a better option, then you could just use the version.yaml file for DB migrations, and map the version number in the YAML file to the version number in the plugin.php, that way you won't always need the YAML file to build a plugin - just a thought for the devs

Last updated

1-4 of 4

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