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-09-27 03:19:40 +03:00
|
|
|
const renameDealsTable = db.schema.renameTable("deals", "old_deals");
|
2021-05-25 01:19:48 +03:00
|
|
|
|
2021-09-27 03:19:40 +03:00
|
|
|
const deleteGlobalTable = db.schema.dropTable("global");
|
2021-05-25 01:19:48 +03:00
|
|
|
|
2021-09-27 03:19:40 +03:00
|
|
|
const deleteStatsTable = db.schema.dropTable("stats");
|
2021-05-25 01:19:48 +03:00
|
|
|
|
2021-09-27 03:19:40 +03:00
|
|
|
const createDealsTable = db.schema.createTable("deals", function (table) {
|
2021-09-28 23:52:21 +03:00
|
|
|
table.uuid("id").primary().unique().notNullable().defaultTo(db.raw("uuid_generate_v4()"));
|
|
|
|
table.string("textileBucketCID").notNullable();
|
|
|
|
table.string("pinCID").notNullable();
|
|
|
|
table.string("requestId").notNullable();
|
2021-09-27 03:19:40 +03:00
|
|
|
table.timestamp("createdAt").notNullable().defaultTo(db.raw("now()"));
|
2021-05-25 01:19:48 +03:00
|
|
|
});
|
|
|
|
|
2021-09-29 00:54:02 +03:00
|
|
|
const deleteStorageDealSettings = db.schema.table("users", function (table) {
|
|
|
|
table.dropColumns(
|
|
|
|
"settingsDealsAutoApprove",
|
|
|
|
"allowEncryptedDataStorage",
|
|
|
|
"allowAutomaticDataStorage"
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
Promise.all([deleteStorageDealSettings]);
|
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.`);
|