Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- exports.up = (knex, Promise) => {
- return Promise.all([
- knex.schema.createTableIfNotExists('cities', table => {
- table.increments('id').primary();
- table.string('city');
- })
- .then(() => {
- return knex("cities").insert([
- {city: "Gliwice"},
- {city: "Wrocław"},
- {city: "Kraków"}
- ])
- }),
- knex.schema.createTableIfNotExists('users', table => {
- table.increments('id').primary();
- table.string('name');
- table.string('email');
- table.integer('city_id').unsigned().index().references('id').inTable('cities');
- })
- .then(() => {
- return knex("users").insert([
- {name: "Andrzej Kopeć", email: "andrzej.kopec@skygate.pl", city_id: 1},
- {name: "Krzysztof Parjaszewski", email: "chris@skygate.pl", city_id: 1},
- {name: "Dawid Ryguła", email: "dawid.rygula@skygate.pl", city_id: 1},
- {name: "Damian Paszkowski", email: "damian.paszkowski@skygate.pl", city_id: 1},
- {name: "Karol Gruszczyk", email: "karol.gruszczyk@skygate.pl", city_id: 1},
- {name: "Tomasz Ferens", email: "tomasz.ferens@skygate.pl", city_id: 1},
- {name: "Marcin Krawczyk", email: "marcin.krawczyk@skygate.pl", city_id: 1},
- {name: "Mateusz Leo", email: "mateusz.leo@skygate.pl", city_id: 1},
- {name: "Łukasz Sojka", email: "lukasz.sojka@skygate.pl", city_id: 1},
- {name: "Jerzy Spendel", email: "jerzy.spendel@skygate.pl", city_id: 1},
- {name: "Justyna Botor", email: "justyna.botor@skygate.pl", city_id: 1},
- {name: "Mariusz Chrobok", email: "mariusz.chrobok@skygate.pl", city_id: 1},
- {name: "Szymon Oboński", email: "szymon.obonski@skygate.pl", city_id: 3},
- {name: "Grzegorz Rauch", email: "grzegorz.rauch@skygate.pl", city_id: 2},
- {name: "Jakub Saniewski", email: "jakub.saniewski@skygate.pl", city_id: 2},
- {name: "Łukasz Werka", email: "lucas.werka@skygate.pl", city_id: 1},
- {name: "Anna-Maria Woroniecka", email: "annamaria.woroniecka@skygate.pl", city_id: 2},
- {name: "Mateusz Piotrowski", email: "mateusz.piotrowski@skygate.pl", city_id: 2},
- ])
- }),
- knex.schema.createTableIfNotExists('availabilities', table => {
- table.increments('id').primary();
- table.dateTime('start');
- table.dateTime('end');
- table.string('available');
- table.integer('user_id').unsigned().index().references('id').inTable('users');
- })
- .then(() => {
- return knex("availabilities").insert([
- {start: "2017-03-20T05:00:00+0000", end: "2017-03-21T21:00:00+0000", available: "remote", user_id: 9},
- {start: "2017-03-20T09:30:00+0000", end: "2017-03-20T22:00:00+0000", available: "available", user_id: 10},
- {start: "2017-03-20T07:30:00+0000", end: "2017-03-20T15:30:00+0000", available: "remote", user_id: 11}
- ])
- }),
- ])
- };
- exports.down = (knex, Promise) => {
- return Promise.all([
- knex.schema.dropTable('users'),
- knex.schema.dropTable('cities'),
- knex.schema.dropTable('availabilities')
- ])
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement