2021-06-11 22:25:58 +03:00
|
|
|
import * as Logging from "~/common/logging";
|
|
|
|
|
2020-07-27 01:37:12 +03:00
|
|
|
import configs from "~/knexfile";
|
|
|
|
import knex from "knex";
|
|
|
|
|
|
|
|
const envConfig = configs["development"];
|
|
|
|
|
2021-06-11 22:25:58 +03:00
|
|
|
Logging.log(`SETUP: database`, envConfig);
|
2020-07-27 01:37:12 +03:00
|
|
|
|
|
|
|
const db = knex(envConfig);
|
|
|
|
|
2021-06-11 22:25:58 +03:00
|
|
|
Logging.log(`RUNNING: adjust.js`);
|
2020-07-27 01:37:12 +03:00
|
|
|
|
2021-06-09 01:53:30 +03:00
|
|
|
const editUsersTable1 = db.schema.table("users", function (table) {
|
|
|
|
table.integer("authVersion").notNullable().defaultTo(1);
|
2021-05-25 01:19:48 +03:00
|
|
|
});
|
|
|
|
|
2021-06-09 01:53:30 +03:00
|
|
|
const editUsersTable2 = db.schema.table("users", function (table) {
|
|
|
|
table.integer("authVersion").notNullable().defaultTo(2).alter();
|
|
|
|
table.string("twitterId").unique().nullable();
|
2021-05-25 01:19:48 +03:00
|
|
|
});
|
|
|
|
|
2021-06-09 01:53:30 +03:00
|
|
|
const editVerificationTable = db.schema.table("verifications", function (table) {
|
|
|
|
table.string("username").nullable();
|
|
|
|
table
|
|
|
|
.enu("type", [
|
|
|
|
"email_verification",
|
|
|
|
"email_twitter_verification",
|
|
|
|
"password_reset",
|
|
|
|
"user_migration",
|
|
|
|
])
|
|
|
|
.defaultTo("email_verification");
|
|
|
|
table.boolean("passwordChanged").nullable();
|
2021-05-25 01:19:48 +03:00
|
|
|
});
|
|
|
|
|
2021-06-09 01:53:30 +03:00
|
|
|
const editTwitterTokenTable = db.schema.table("twitterTokens", function (table) {
|
|
|
|
table.string("token").primary().unique().notNullable();
|
|
|
|
table.string("tokenSecret").notNullable();
|
|
|
|
table.string("email").nullable();
|
|
|
|
table.string("id_str").nullable();
|
|
|
|
table.string("screen_name").nullable();
|
|
|
|
table.string("verified").nullable();
|
2021-05-25 01:19:48 +03:00
|
|
|
});
|
|
|
|
|
2021-06-09 01:53:30 +03:00
|
|
|
Promise.all([editVerificationTable]);
|
|
|
|
// Promise.all([editUsersTable1]);
|
|
|
|
// Promise.all([editUsersTable2, editVerificationTable, editTwitterTokenTable]);
|
2020-07-27 01:37:12 +03:00
|
|
|
|
2021-06-11 22:25:58 +03:00
|
|
|
Logging.log(`FINISHED: adjust.js`);
|
|
|
|
Logging.log(` CTRL +C to return to terminal.`);
|