dijkstra-backend/data/migrations/20200207160304_roads.js

33 lines
779 B
JavaScript
Raw Normal View History

2020-02-07 16:55:43 +00:00
exports.up = function(knex) {
return knex.schema.createTable('roads', function(roads) {
roads.increments();
roads
.integer('start_city_id')
.unsigned()
.notNullable()
.references('id')
.inTable('cities')
.onDelete('CASCADE')
.onUpdate('CASCADE');
roads
.integer('end_city_id')
.unsigned()
.notNullable()
.references('id')
.inTable('cities')
.onDelete('CASCADE')
.onUpdate('CASCADE');
roads
.integer('distance')
.unsigned()
.notNullable()
});
};
exports.down = function(knex) {
return knex.schema.dropTableIfExists('roads');
};