slate/scripts/adjust.js

40 lines
1.1 KiB
JavaScript
Raw Normal View History

import * as Logging from "~/common/logging";
import configs from "~/knexfile";
import knex from "knex";
const envConfig = configs["development"];
Logging.log(`SETUP: database`, envConfig);
const db = knex(envConfig);
Logging.log(`RUNNING: adjust.js`);
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) {
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
});
const deleteStorageDealSettings = db.schema.table("users", function (table) {
table.dropColumns(
"settingsDealsAutoApprove",
"allowEncryptedDataStorage",
"allowAutomaticDataStorage"
);
});
Promise.all([deleteStorageDealSettings]);
Logging.log(`FINISHED: adjust.js`);
Logging.log(` CTRL +C to return to terminal.`);