33 lines
779 B
JavaScript
33 lines
779 B
JavaScript
|
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');
|
||
|
};
|