Built motion from commit b33b832.|1.0.17
[motion.git] / server / migrations / 20170403111147-users.js
1 'use strict';
2
3 module.exports = {
4   up: function(queryInterface, Sequelize) {
5     return queryInterface.removeIndex('users', 'fullname')
6       .catch(function(err) {
7         console.error(err);
8       })
9       .then(function() {
10         queryInterface.changeColumn(
11           'users',
12           'fullname', {
13             type: Sequelize.STRING,
14             allowNull: false,
15             unique: false
16           }
17         );
18       })
19       .catch(function(err) {
20         console.error(err);
21       })
22       .then(function() {
23         queryInterface.sequelize.query('set foreign_key_checks = 0');
24       })
25       .catch(function(err) {
26         console.error(err);
27       })
28       .then(function() {
29         queryInterface.sequelize.query('DROP INDEX `fullname_2` ON users;');
30       })
31       .catch(function(err) {
32         console.error(err);
33       })
34       .then(function() {
35         queryInterface.sequelize.query('DROP INDEX `users_email_unique` ON users;');
36       })
37       .catch(function(err) {
38         console.error(err);
39       })
40       .then(function() {
41         queryInterface.sequelize.query('DROP INDEX `users_fullname_unique` ON users;');
42       })
43       .catch(function(err) {
44         console.error(err);
45       })
46       .then(function() {
47         queryInterface.sequelize.query('DROP INDEX `users_internal_unique` ON users;');
48       })
49       .catch(function(err) {
50         console.error(err);
51       })
52       .then(function() {
53         queryInterface.sequelize.query('DROP INDEX `users_name_unique` ON users;');
54       })
55       .catch(function(err) {
56         console.error(err);
57       })
58       .then(function() {
59         queryInterface.sequelize.query('set foreign_key_checks = 1');
60       })
61       .catch(function(err) {
62         console.error(err);
63       });
64   },
65
66   down: function(queryInterface, Sequelize) {
67     /*
68       Add reverting commands here.
69       Return a promise to correctly handle asynchronicity.
70
71       Example:
72       return queryInterface.dropTable('users');
73     */
74   }
75 };