AdonisJS
MySQL
https://adonisjs.com/docs/4.1/database
npm i mysql --save
.env
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_USER=root DB_PASSWORD=password DB_DATABASE=adonis
Migration
adonis make:migration customer
database/migrations/1601508757714_customer_schema.js
'use strict' /** @type {import('@adonisjs/lucid/src/Schema')} */ const Schema = use('Schema') class CustomerSchema extends Schema { up () { this.create('customers', (table) => { table.increments() table.string('name', 100).notNullable() table.string('email', 80).notNullable().unique() table.string('address', 100) table.bigInteger('phone', 100) table.timestamps() }) } down () { this.drop('customers') } } module.exports = CustomerSchema
Status migration
adonis migration:status
Run migration
adonis migration:run
Model
adonis make:model Customer
app/Models/Customer.js
'use strict' /** @type {typeof import('@adonisjs/lucid/src/Lucid/Model')} */ const Model = use('Model') class Customer extends Model { static get table () { return 'customers' } // static get createdAtColumn () { // return null // } // // static get updatedAtColumn () { // return null // } } module.exports = Customer
https://adonisjs.com/docs/4.0/lucid