Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. 'use strict';
  2.  
  3. var dbm;
  4. var type;
  5. var seed;
  6.  
  7. /**
  8. * We receive the dbmigrate dependency from dbmigrate initially.
  9. * This enables us to not have to rely on NODE_PATH.
  10. */
  11. exports.setup = function(options, seedLink) {
  12. dbm = options.dbmigrate;
  13. type = dbm.dataType;
  14. seed = seedLink;
  15. };
  16.  
  17. exports.up = function(db) {
  18.  
  19. db.createTable('appointments', {
  20. columns: {
  21. id: {type: 'int', primaryKey: true, autoIncrement: true},
  22. title: {type: 'string', length: 255, notNull: true},
  23. description: {type: 'string', length: 255},
  24. startTime: {type: 'datetime', notNull: true},
  25. endTime: {type: 'datetime'},
  26. userId: {type: 'int', length: 11, notNull: true},
  27. createdAt: {type: 'datetime'},
  28. updatedAt: {type: 'datetime'}
  29. },
  30. ifNotExists: true
  31. });
  32.  
  33. db.createTable('users', {
  34. columns: {
  35. id: {type: 'int', primaryKey: true, autoIncrement: true},
  36. email: {type: 'string', length: 255, notNull: true},
  37. password: {type: 'string', length: 255, notNull: true},
  38. firstName: {type: 'string', length: 255},
  39. lastName: {type: 'string', length: 255},
  40. addressOne: {type: 'string', length: 255},
  41. addressTwo: {type: 'string', length: 255},
  42. city: {type: 'string', length: 255},
  43. state: {type: 'string', length: 255},
  44. zip: {type: 'string', length: 255},
  45. country: {type: 'string', length: 255},
  46. phone: {type: 'string', length: 255},
  47. createdAt: {type: 'datetime'},
  48. updatedAt: {type: 'datetime'}
  49. },
  50. ifNotExists: true
  51. });
  52.  
  53. db.createTable('contacts', {
  54. columns: {
  55. id: {type: 'int', primaryKey: true, autoIncrement: true},
  56. email: {type: 'string', length: 255, notNull: true},
  57. firstName: {type: 'string', length: 255},
  58. lastName: {type: 'string', length: 255},
  59. addressOne: {type: 'string', length: 255},
  60. addressTwo: {type: 'string', length: 255},
  61. city: {type: 'string', length: 255},
  62. state: {type: 'string', length: 255},
  63. zip: {type: 'string', length: 255},
  64. country: {type: 'string', length: 255},
  65. phone: {type: 'string', length: 255},
  66. createdAt: {type: 'datetime'},
  67. updatedAt: {type: 'datetime'}
  68. },
  69. ifNotExists: true
  70. });
  71.  
  72. db.createTable('notes', {
  73. columns: {
  74. id: {type: 'int', primaryKey: true, autoIncrement: true},
  75. appointmentId: {type: 'int', length: 11},
  76. contactId: {type: 'int', length: 11},
  77. title: {type: 'string', length: 255, notNull: true},
  78. content: {type: 'text'},
  79. createdAt: {type: 'datetime'},
  80. updatedAt: {type: 'datetime'}
  81. },
  82. ifNotExists: true
  83. });
  84.  
  85. db.createTable('appointment_contacts', {
  86. columns: {
  87. id: {type: 'int', primaryKey: true, autoIncrement: true},
  88. appointmentId: {type: 'int', length: 11, notNull: true},
  89. contactId: {type: 'int', length: 11, notNull: true},
  90. createdAt: {type: 'datetime'},
  91. updatedAt: {type: 'datetime'}
  92. },
  93. ifNotExists: true
  94. });
  95. };
  96.  
  97. exports.down = function(db) {
  98. db.dropTable('appointments');
  99. db.dropTable('users');
  100. db.dropTable('contacts');
  101. db.dropTable('notes');
  102. db.dropTable('appointment_contacts');
  103. };
  104.  
  105. exports._meta = {
  106. "version": 1
  107. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement