Implemented some of api keys
This commit is contained in:
46
server/migrations/20160824061730-add-apikeys.js
Normal file
46
server/migrations/20160824061730-add-apikeys.js
Normal file
@@ -0,0 +1,46 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
up: function (queryInterface, Sequelize) {
|
||||
queryInterface.createTable('apiKeys', {
|
||||
id: {
|
||||
type: 'UUID',
|
||||
allowNull: false,
|
||||
primaryKey: true,
|
||||
},
|
||||
name: {
|
||||
type: 'CHARACTER VARYING',
|
||||
allowNull: true,
|
||||
},
|
||||
secret: {
|
||||
type: 'CHARACTER VARYING',
|
||||
allowNull: false,
|
||||
unique: true,
|
||||
},
|
||||
userId: {
|
||||
type: 'UUID',
|
||||
allowNull: true,
|
||||
// references: {
|
||||
// model: 'users',
|
||||
// key: 'id',
|
||||
// },
|
||||
},
|
||||
createdAt: {
|
||||
type: 'TIMESTAMP WITH TIME ZONE',
|
||||
allowNull: false,
|
||||
},
|
||||
updatedAt: {
|
||||
type: 'TIMESTAMP WITH TIME ZONE',
|
||||
allowNull: false,
|
||||
},
|
||||
deletedAt: {
|
||||
type: 'TIMESTAMP WITH TIME ZONE',
|
||||
allowNull: true,
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
down: function (queryInterface, Sequelize) {
|
||||
queryInterface.createTable('apiKeys');
|
||||
},
|
||||
};
|
||||
13
server/migrations/20160824062457-add-apikey-indeces.js
Normal file
13
server/migrations/20160824062457-add-apikey-indeces.js
Normal file
@@ -0,0 +1,13 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
up: function (queryInterface, Sequelize) {
|
||||
queryInterface.addIndex('apiKeys', ['secret', 'deletedAt']);
|
||||
queryInterface.addIndex('apiKeys', ['userId', 'deletedAt']);
|
||||
},
|
||||
|
||||
down: function (queryInterface, Sequelize) {
|
||||
queryInterface.removeIndex('apiKeys', ['secret', 'deletedAt']);
|
||||
queryInterface.removeIndex('apiKeys', ['userId', 'deletedAt']);
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user