Advertisement
Guest User

Untitled

a guest
Apr 11th, 2017
605
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. exports.up = (knex, Promise) => {
  2.     return Promise.all([
  3.         knex.schema.createTableIfNotExists('cities', table => {
  4.             table.increments('id').primary();
  5.             table.string('city');
  6.         })
  7.         .then(() => {
  8.             return knex("cities").insert([
  9.                 {city: "Gliwice"},
  10.                 {city: "Wrocław"},
  11.                 {city: "Kraków"}
  12.             ])
  13.         }),
  14.         knex.schema.createTableIfNotExists('users', table => {
  15.             table.increments('id').primary();
  16.             table.string('name');
  17.             table.string('email');
  18.  
  19.             table.integer('city_id').unsigned().index().references('id').inTable('cities');
  20.         })
  21.         .then(() => {
  22.             return knex("users").insert([
  23.                 {name: "Andrzej Kopeć", email: "andrzej.kopec@skygate.pl", city_id: 1},
  24.                 {name: "Krzysztof Parjaszewski", email: "chris@skygate.pl", city_id: 1},
  25.                 {name: "Dawid Ryguła", email: "dawid.rygula@skygate.pl", city_id: 1},
  26.                 {name: "Damian Paszkowski", email: "damian.paszkowski@skygate.pl", city_id: 1},
  27.                 {name: "Karol Gruszczyk", email: "karol.gruszczyk@skygate.pl", city_id: 1},
  28.                 {name: "Tomasz Ferens", email: "tomasz.ferens@skygate.pl", city_id: 1},
  29.                 {name: "Marcin Krawczyk", email: "marcin.krawczyk@skygate.pl", city_id: 1},
  30.                 {name: "Mateusz Leo", email: "mateusz.leo@skygate.pl", city_id: 1},
  31.                 {name: "Łukasz Sojka", email: "lukasz.sojka@skygate.pl", city_id: 1},
  32.                 {name: "Jerzy Spendel", email: "jerzy.spendel@skygate.pl", city_id: 1},
  33.                 {name: "Justyna Botor", email: "justyna.botor@skygate.pl", city_id: 1},
  34.                 {name: "Mariusz Chrobok", email: "mariusz.chrobok@skygate.pl", city_id: 1},
  35.                 {name: "Szymon Oboński", email: "szymon.obonski@skygate.pl", city_id: 3},
  36.                 {name: "Grzegorz Rauch", email: "grzegorz.rauch@skygate.pl", city_id: 2},
  37.                 {name: "Jakub Saniewski", email: "jakub.saniewski@skygate.pl", city_id: 2},
  38.                 {name: "Łukasz Werka", email: "lucas.werka@skygate.pl", city_id: 1},
  39.                 {name: "Anna-Maria Woroniecka", email: "annamaria.woroniecka@skygate.pl", city_id: 2},
  40.                 {name: "Mateusz Piotrowski", email: "mateusz.piotrowski@skygate.pl", city_id: 2},
  41.             ])
  42.         }),
  43.         knex.schema.createTableIfNotExists('availabilities', table => {
  44.             table.increments('id').primary();
  45.             table.dateTime('start');
  46.             table.dateTime('end');
  47.             table.string('available');
  48.  
  49.             table.integer('user_id').unsigned().index().references('id').inTable('users');
  50.         })
  51.         .then(() => {
  52.             return knex("availabilities").insert([
  53.                 {start: "2017-03-20T05:00:00+0000", end: "2017-03-21T21:00:00+0000", available: "remote", user_id: 9},
  54.                 {start: "2017-03-20T09:30:00+0000", end: "2017-03-20T22:00:00+0000", available: "available", user_id: 10},
  55.                 {start: "2017-03-20T07:30:00+0000", end: "2017-03-20T15:30:00+0000", available: "remote", user_id: 11}
  56.             ])
  57.         }),
  58.     ])
  59. };
  60.  
  61. exports.down = (knex, Promise) => {
  62.     return Promise.all([
  63.         knex.schema.dropTable('users'),
  64.         knex.schema.dropTable('cities'),
  65.         knex.schema.dropTable('availabilities')
  66.     ])
  67. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement