computamike / adonis-schema-builder

Schema Builder for AdonisJS / Lucid. Generates migrations, models, seeds and tests for Adonis apps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Adonis Schema Builder

NPM Package License Build Status Coverage Status Maintainability Dependencies Greenkeeper badge

Build adonis migrations, factories and models with pre-configured relationships from Database Schema.

Based on a schema-builder for laravel and using the same schema format as schema-designer.

Installation

This package works with AdonisJS v4. In your project directory you'll need ace, fold and cli installed:

npm install --save @adonisjs/ace @adonisjs/cli @adonisjs/fold

Then install adonis-schema-builder:

npm install --save adonis-schema-builder

You should now see the schema:build option when running adonis or ace.

How to use

Creating a Schema

Use the schema-builder GUI to design your schema, and export as JSON. All of the table and column options in the schema builder are supported, although some column types may be substituted to supported Knex types.

Importing the Schema

Run adonis schema:build <path to schema file> from the project root to import the schema file and generate source files. You will be asked to confirm before overwriting any existing files.

Generated files

  • A create table migration for each table.
  • A model for each table (except link tables) including validator and sanitisation rules and relationships.
  • A factory js file, with a blueprint for each model.

Caveats

  • Link tables (tables that exist only to join other models) must be denoted with an underscore (i.e. post_category)

Upcoming features

  • Validator message - Messages corresponding to validator rules
  • Seeds - use the factories to create a seed file that creates entities that follow the relationship rules.
  • Tests - generate integration tests to check that models and factories are set up correctly and are compatible with adonis-lucid.

About

Schema Builder for AdonisJS / Lucid. Generates migrations, models, seeds and tests for Adonis apps


Languages

Language:JavaScript 97.0%Language:HTML 3.0%