Answers for "knex js join schema"

2

knex migration

// best tutorial knex migration
https://www.youtube.com/watch?v=ipAH7lMfq7k
https://www.youtube.com/watch?v=U7GjS3FuSkA
Posted by: Guest on November-04-2020
1

knex datatypes

table.increments('id')
  table.string('account_name')
  table.integer('age')
  table.float('age')
  table.decimal('balance', 8, 2)
  table.boolean('is_admin')
  table.date('birthday')
  table.time('created_at')
  table.timestamp('created_at').defaultTo(knex.fn.now())
  table.json('profile')
  table.jsonb('profile')
  table.uuid('id').primary()
Posted by: Guest on September-09-2020
0

knex js join schema

exports.up = (knex) => {
  knex.schema.createTable('bookings', (table) => {
    table.increment('booking_id').primary()
    table.foreign('user_id').references('user_id').inTable('users').notNullable().onDelete('CASCADE').index()
    table.foreign('room_id').references('room_id').inTable('rooms').notNullable().onDelete('CASCADE').index()
    table.integer('total_person').notNullable().defaultTo(0)
    table.datetime('booking_time').notNullable().defaultTo(knex.fn.now())
    table.string('noted').notNullable()
    table.datetime('check_in_time').defaultTo(knex.fn.now())
    table.datetime('check_out_time').defaultTo(knex.fn.now())
    table.timestamp('created_at').defaultTo(knex.fn.now())
    table.timestamp('update_at').defaultTo(knex.fn.now())
    table.timestamp('delete_at').defaultTo(knex.fn.now())
  })
}

exports.down = (knex) => knex.schema.dropTable('bookings')
Posted by: Guest on December-15-2020
0

knexjs execute all migrations

$ knex migrate:make create_users_table
$ knex migrate:make create_tasks_table
Posted by: Guest on November-17-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language