Skip to content

Module Migration Generator

Blair Jersyer edited this page Apr 8, 2018 · 5 revisions

The module migration helps you to create database migration for a specific module. it can be acheive quickly using the Migration Generator Command on Artisan Console. Here is the basic schema of the artisan command.

Command Structure

module:migration {module namespace} {--delete=}

Module Namepace

is a required feature which let you define on which module this migration will be created. The namespace should be written as it's defined on the module config.xml file.

--delete option

If provided, this option let you delete migrations folders. The option can be "all" or a specific version number "1.0". If "all" is provided as options all migrations folders will be deleted, otherwise only the specific version number folder will be deleted.

Schema Structure

This command let you build the schema directly while providing the migration name. Here is the structure to create a schema (right after having runned the first command).

{migration file name} --table={table name} --schema={schema structure}

File Name

it can be anything with spaces. Keeping it simple is adviced.

--table option

Let you define the migration table name, with no spaces or any special characters

--schema option

Let you defined the schema structure. It's structured as following :

--schema={column name}:{column type}|{second column name}:{column type}

The column type are defined as on Laravel Schema Column methods name. If the field type is not provided, the default field type "string" is used by default. Here is an example :

php artisan module:migration Foo

> Create Foo Table --table=foo --schema=title:string|message:text

  • Hooks

  • Actions

  • Filters

  • API Endpoint

Clone this wiki locally