brainz-social-old/migrations/20231002234759-oauthCode.js

43 lines
1,023 B
JavaScript
Raw Normal View History

2023-10-02 19:38:21 -05:00
"use strict";
const async = require("async");
let dbm;
let type;
let seed;
/**
* We receive the dbmigrate dependency from dbmigrate initially.
* This enables us to not have to rely on NODE_PATH.
*/
2023-10-08 23:14:04 -05:00
exports.setup = function (options, seedLink) {
2023-10-02 19:38:21 -05:00
dbm = options.dbmigrate;
type = dbm.dataType;
seed = seedLink;
};
2023-10-08 23:14:04 -05:00
exports.up = function (db, callback) {
2023-10-02 19:38:21 -05:00
async.series([
db.createTable.bind(db, "oauth_code", {
id: {type: "int", primaryKey: true, autoIncrements: true},
code: {type: "string", unique: true},
application_id: "int",
scopes: "string",
user_id: "int",
2023-10-08 23:14:04 -05:00
created_at: "int",
2023-10-02 19:38:21 -05:00
}),
2023-10-08 23:14:04 -05:00
db.addIndex.bind(db, "oauth_code", "oauth_code_index", ["code"]),
2023-10-02 19:38:21 -05:00
], callback);
};
2023-10-08 23:14:04 -05:00
exports.down = function (db, callback) {
2023-10-02 19:38:21 -05:00
async.series([
db.removeIndex.bind(db, "oauth_code", "oauth_code_index"),
2023-10-08 23:14:04 -05:00
db.dropTable.bind(db, "oauth_code"),
2023-10-02 19:38:21 -05:00
], callback);
};
exports._meta = {
2023-10-08 23:14:04 -05:00
version: 1,
2023-10-02 19:38:21 -05:00
};