realpython/members

View on GitHub
src/server/db/migrations/20160629101603_lessons.js

Summary

Maintainability
A
0 mins
Test Coverage
exports.up = (knex, Promise) => {
  return knex.schema.createTable('lessons', (table) => {
    table.increments();
    table.integer('lesson_order_number').notNullable();
    table.integer('chapter_order_number').notNullable();
    table.string('name').unique().notNullable();
    table.text('content').notNullable();
    table.boolean('active').notNullable().defaultTo(true);
    table.integer('chapter_id').references('id').inTable('chapters').notNullable();
    table.timestamp('created_at').defaultTo(knex.fn.now());
  });
};

exports.down = (knex, Promise) => {
  return knex.schema.dropTable('lessons');
};