Skip to content
Permalink
Browse files

03 Database Migrations - Creating Tables

  • Loading branch information
alarner committed Jul 17, 2016
1 parent 25b5dde commit f0ff5c1335ad1f54d4e279b5f0b1c1e40a74be06
Showing with 37 additions and 0 deletions.
  1. +19 −0 migrations/20160716165612_create_links.js
  2. +18 −0 migrations/20160716165623_create_images.js
@@ -0,0 +1,19 @@

exports.up = function(knex, Promise) {
return knex.schema.createTable('links', function(t) {
t.increments('id').unsigned().primary();
t.datetime('createdAt').notNull();
t.datetime('updatedAt').nullable();
t.datetime('deletedAt').nullable();

t.string('label').notNull();
t.string('url').notNull();

t.integer('order').notNull();
t.integer('userId').notNull().references('id').inTable('users').onDelete('CASCADE');
});
};

exports.down = function(knex, Promise) {
return knex.schema.dropTable('links');
};
@@ -0,0 +1,18 @@

exports.up = function(knex, Promise) {
return knex.schema.createTable('images', function(t) {
t.increments('id').unsigned().primary();
t.datetime('createdAt').notNull();
t.datetime('updatedAt').nullable();
t.datetime('deletedAt').nullable();

t.string('originalFileName').notNull();
t.string('original').notNull();
t.string('medium').nullable();
t.string('small').nullable();
});
};

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

0 comments on commit f0ff5c1

Please sign in to comment.
You can’t perform that action at this time.