Add initial version of dijkstra backend cloudron image
This commit is contained in:
13
data/migrations/20200207155645_countries.js
Normal file
13
data/migrations/20200207155645_countries.js
Normal file
@@ -0,0 +1,13 @@
|
||||
exports.up = function(knex, Promise) {
|
||||
return knex.schema.createTable('countries', function(countries) {
|
||||
countries.increments();
|
||||
countries
|
||||
.string('name', 128)
|
||||
.notNullable()
|
||||
.unique();
|
||||
});
|
||||
};
|
||||
|
||||
exports.down = function(knex, Promise) {
|
||||
return knex.schema.dropTableIfExists('countries');
|
||||
};
|
||||
20
data/migrations/20200207160031_cities.js
Normal file
20
data/migrations/20200207160031_cities.js
Normal file
@@ -0,0 +1,20 @@
|
||||
exports.up = function(knex) {
|
||||
return knex.schema.createTable('cities', function(cities) {
|
||||
cities.increments();
|
||||
|
||||
cities.string('name', 128).notNullable();
|
||||
cities
|
||||
.integer('country_id')
|
||||
.unsigned()
|
||||
.notNullable()
|
||||
.references('id')
|
||||
.inTable('countries')
|
||||
.onDelete('CASCADE')
|
||||
.onUpdate('CASCADE');
|
||||
});
|
||||
};
|
||||
|
||||
exports.down = function(knex) {
|
||||
return knex.schema.dropTableIfExists('cities');
|
||||
};
|
||||
|
||||
32
data/migrations/20200207160304_roads.js
Normal file
32
data/migrations/20200207160304_roads.js
Normal file
@@ -0,0 +1,32 @@
|
||||
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');
|
||||
};
|
||||
Reference in New Issue
Block a user