brainz-social-old/migrations/20230926224347-applications.js

44 lines
1.1 KiB
JavaScript
Raw Normal View History

2023-09-28 18:54:38 -05:00
"use strict";
2023-09-27 07:03:36 -05:00
2023-09-28 18:54:38 -05:00
const async = require("async");
2023-09-27 07:03:36 -05:00
2023-09-30 16:53:27 -05:00
let dbm;
let type;
let seed;
2023-09-27 07:03:36 -05:00
/**
* 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-09-28 18:54:38 -05:00
dbm = options.dbmigrate;
type = dbm.dataType;
seed = seedLink;
2023-09-27 07:03:36 -05:00
};
2023-10-08 23:14:04 -05:00
exports.up = function (db, callback) {
2023-09-28 18:54:38 -05:00
async.series([
db.createTable.bind(db, "applications", {
2023-10-08 23:14:04 -05:00
id: {type: "int", primaryKey: true, autoIncrement: true},
2023-09-28 18:54:38 -05:00
client_name: "string",
redirect_uri: "string",
scopes: "string",
website: "string",
2023-10-08 23:14:04 -05:00
client_id: {type: "string", unique: true},
client_secret: "string",
2023-09-28 18:54:38 -05:00
}),
2023-10-08 23:14:04 -05:00
db.addIndex.bind(db, "applications", "clientIdIndex", ["client_id"], true),
2023-09-28 18:54:38 -05:00
], callback);
2023-09-27 07:03:36 -05:00
};
2023-10-08 23:14:04 -05:00
exports.down = function (db, callback) {
2023-09-28 18:54:38 -05:00
async.series([
db.removeIndex.bind(db, "applications", "clientIdIndex"),
2023-10-08 23:14:04 -05:00
db.dropTable.bind(db, "applications"),
2023-09-28 18:54:38 -05:00
], callback);
2023-09-27 07:03:36 -05:00
};
exports._meta = {
2023-10-08 23:14:04 -05:00
version: 1,
2023-09-27 07:03:36 -05:00
};