Download the PHP package bitsnio/json-to-migration-laravel without Composer
On this page you can find all versions of the php package bitsnio/json-to-migration-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bitsnio/json-to-migration-laravel
More information about bitsnio/json-to-migration-laravel
Files in bitsnio/json-to-migration-laravel
Package json-to-migration-laravel
Short Description Turn a JSON schema into Laravel migrations.
License MIT
Informations about the package json-to-migration-laravel
JSON to Laravel Migrations
Simply create a .json file with the schema for your database, and run the artisan command json:migrate Template.json
to create all the migrations for your project.
Note: This package is built to be used to kickstart your Laravel projects, and not to use on something that's already been built.
Installation
You can install this package by running the below composer command:
Creating the JSON Template
Create a Template.json
file in the root of your project, and use a template like the below:
The main keys of your JSON represent the table names. Make sure to create them in order in case a table has a relationship with another. In this case, posts
, categories
, and subcategories
are our tables.
Next, for each table, define your columns as keys (so name
, state
, text
, ... in this case), and set their properties.
Properties
Properties are separated with a pipe (|
), and the first property should always be the column type. The package supports every column type in Laravel.
Additional options (such as string length) can be supplied using a colon (:
), followed by the value of the option. Multiple options can be supplied (for float
, for example).
Migrations
Run the above using:
The above schema will create something three different migrations. The posts
schema will look like: