brainz-social-old/migrations/20230928130221-accounts.js

40 lines
969 B
JavaScript
Raw Normal View History

2023-09-28 18:54:38 -05:00
"use strict";
2023-09-28 18:36:35 -05:00
2023-09-30 16:53:27 -05:00
let dbm;
let type;
let seed;
2023-09-28 18:36:35 -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-28 18:36:35 -05:00
};
2023-10-08 23:14:04 -05:00
exports.up = function (db, callback) {
db.createTable("accounts", {
2023-10-08 23:14:04 -05:00
id: {type: "int", primaryKey: true, autoIncrement: true},
username: {type: "string", unique: true},
email: "string",
password_hash: "string",
2023-10-08 23:14:04 -05:00
account_tier: "int",
}, (result) => {
if (result) {
callback(result);
}
db.runSql("INSERT INTO \"accounts\" (\"username\",\"email\",\"password_hash\",\"account_tier\") VALUES (\"guest\",\"null@null.null\",\"purposely_invalid_password\",0);", callback);
});
2023-09-28 18:36:35 -05:00
};
2023-10-08 23:14:04 -05:00
exports.down = function (db) {
2023-09-28 18:54:38 -05:00
return db.dropTable("accounts");
2023-09-28 18:36:35 -05:00
};
exports._meta = {
2023-10-08 23:14:04 -05:00
version: 1,
2023-09-28 18:36:35 -05:00
};