mirror of
https://github.com/filecoin-project/slate.git
synced 2024-12-25 18:13:10 +03:00
feat(DB/Surveys): update database scripts with the surveys table changes
This commit is contained in:
parent
1faaba264c
commit
5f893bb1f8
@ -2,18 +2,16 @@ import { runQuery } from "~/node_common/data/utilities";
|
||||
|
||||
export default async ({
|
||||
ownerId,
|
||||
prevToolsDropbox,
|
||||
prevToolsArena,
|
||||
prevToolsPinterest,
|
||||
prevToolsGoogleDrive,
|
||||
prevToolsBrowserBookmarks,
|
||||
prevToolsPinterest,
|
||||
prevToolsArena,
|
||||
prevToolsNotesPlatform,
|
||||
prevToolsOther,
|
||||
|
||||
useCasesPersonalStorage,
|
||||
useCasesPublicFileSharing,
|
||||
useCasesArchiving,
|
||||
useCasesBookmarking,
|
||||
useCasesMoodboarding,
|
||||
useCasesBookmarkingImportantPages,
|
||||
useCasesSavingLinksToReadLater,
|
||||
useCasesSearchingYourBrowsedPages,
|
||||
useCasesSharingCollectionsOfLinks,
|
||||
useCasesOther,
|
||||
|
||||
referralFriend,
|
||||
@ -26,19 +24,16 @@ export default async ({
|
||||
queryFn: async (DB) => {
|
||||
let query = await DB.insert({
|
||||
ownerId,
|
||||
|
||||
prevToolsDropbox,
|
||||
prevToolsArena,
|
||||
prevToolsPinterest,
|
||||
prevToolsGoogleDrive,
|
||||
prevToolsBrowserBookmarks,
|
||||
prevToolsPinterest,
|
||||
prevToolsArena,
|
||||
prevToolsNotesPlatform,
|
||||
prevToolsOther,
|
||||
|
||||
useCasesPersonalStorage,
|
||||
useCasesPublicFileSharing,
|
||||
useCasesArchiving,
|
||||
useCasesBookmarking,
|
||||
useCasesMoodboarding,
|
||||
useCasesBookmarkingImportantPages,
|
||||
useCasesSavingLinksToReadLater,
|
||||
useCasesSearchingYourBrowsedPages,
|
||||
useCasesSharingCollectionsOfLinks,
|
||||
useCasesOther,
|
||||
|
||||
referralFriend,
|
||||
|
@ -11,6 +11,15 @@ const db = knex(envConfig);
|
||||
|
||||
Logging.log(`RUNNING: adjust.js`);
|
||||
|
||||
const dropColumnIfExists = async (tableName, columnName) => {
|
||||
const hasColumn = await db.schema.hasColumn(tableName, columnName);
|
||||
if (hasColumn) {
|
||||
return db.schema.alterTable(tableName, (table) => {
|
||||
table.dropColumn(columnName);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const renameDealsTable = db.schema.renameTable("deals", "old_deals");
|
||||
|
||||
const deleteGlobalTable = db.schema.dropTable("global");
|
||||
@ -42,32 +51,53 @@ const addSlateCoverImage = db.schema.table("slates", function (table) {
|
||||
table.jsonb("coverImage").nullable();
|
||||
});
|
||||
|
||||
const createSurveysTable = db.schema.table("surveys", function (table) {
|
||||
table.uuid("id").primary().unique().notNullable().defaultTo(db.raw("uuid_generate_v4()"));
|
||||
table.uuid("ownerId").references("id").inTable("users");
|
||||
const createSurveysTable = (async () => {
|
||||
const exists = await db.schema.hasTable("surveys");
|
||||
if (exists) {
|
||||
return Promise.all([
|
||||
dropColumnIfExists("surveys", "prevToolsDropbox"),
|
||||
dropColumnIfExists("surveys", "prevToolsGoogleDrive"),
|
||||
dropColumnIfExists("surveys", "useCasesPersonalStorage"),
|
||||
dropColumnIfExists("surveys", "useCasesPublicFileSharing"),
|
||||
dropColumnIfExists("surveys", "useCasesArchiving"),
|
||||
dropColumnIfExists("surveys", "useCasesBookmarking"),
|
||||
dropColumnIfExists("surveys", "useCasesMoodboarding"),
|
||||
db.schema.alterTable("surveys", (table) => {
|
||||
table.boolean("prevToolsNotesPlatform").defaultTo(false);
|
||||
|
||||
// What do you currently use for saving things on the web?
|
||||
table.boolean("prevToolsDropbox").defaultTo(false);
|
||||
table.boolean("prevToolsArena").defaultTo(false);
|
||||
table.boolean("prevToolsPinterest").defaultTo(false);
|
||||
table.boolean("prevToolsGoogleDrive").defaultTo(false);
|
||||
table.boolean("prevToolsBrowserBookmarks").defaultTo(false);
|
||||
table.string("prevToolsOther").defaultTo(null);
|
||||
table.boolean("useCasesBookmarkingImportantPages").defaultTo(false);
|
||||
table.boolean("useCasesSavingLinksToReadLater").defaultTo(false);
|
||||
table.boolean("useCasesSearchingYourBrowsedPages").defaultTo(false);
|
||||
table.boolean("useCasesSharingCollectionsOfLinks").defaultTo(false);
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
// What are you interested in using Slate for?
|
||||
table.boolean("useCasesPersonalStorage").defaultTo(false);
|
||||
table.boolean("useCasesPublicFileSharing").defaultTo(false);
|
||||
table.boolean("useCasesArchiving").defaultTo(false);
|
||||
table.boolean("useCasesBookmarking").defaultTo(false);
|
||||
table.boolean("useCasesMoodboarding").defaultTo(false);
|
||||
table.string("useCasesOther").defaultTo(null);
|
||||
return db.schema.createTable("surveys", function (table) {
|
||||
table.uuid("id").primary().unique().notNullable().defaultTo(db.raw("uuid_generate_v4()"));
|
||||
table.uuid("ownerId").references("id").inTable("users");
|
||||
|
||||
// How did you find out about Slate?
|
||||
table.boolean("referralFriend").defaultTo(false);
|
||||
table.boolean("referralTwitter").defaultTo(false);
|
||||
table.boolean("referralIpfsFilecoinCommunity").defaultTo(false);
|
||||
table.string("referralOther").defaultTo(null);
|
||||
});
|
||||
// What do you currently use for saving things on the web?
|
||||
table.boolean("prevToolsBrowserBookmarks").defaultTo(false);
|
||||
table.boolean("prevToolsPinterest").defaultTo(false);
|
||||
table.boolean("prevToolsArena").defaultTo(false);
|
||||
table.boolean("prevToolsNotesPlatform").defaultTo(false);
|
||||
table.string("prevToolsOther").defaultTo(null);
|
||||
|
||||
// What are you interested in using Slate for?
|
||||
table.boolean("useCasesBookmarkingImportantPages").defaultTo(false);
|
||||
table.boolean("useCasesSavingLinksToReadLater").defaultTo(false);
|
||||
table.boolean("useCasesSearchingYourBrowsedPages").defaultTo(false);
|
||||
table.boolean("useCasesSharingCollectionsOfLinks").defaultTo(false);
|
||||
table.string("useCasesOther").defaultTo(null);
|
||||
|
||||
// How did you find out about Slate?
|
||||
table.boolean("referralFriend").defaultTo(false);
|
||||
table.boolean("referralTwitter").defaultTo(false);
|
||||
table.boolean("referralIpfsFilecoinCommunity").defaultTo(false);
|
||||
table.string("referralOther").defaultTo(null);
|
||||
});
|
||||
})();
|
||||
|
||||
const dropOnboardingTable = db.schema.dropTableIfExists("onboarding");
|
||||
const addOnboardingColumnsToUsersTable = db.schema.table("users", function (table) {
|
||||
|
@ -192,19 +192,17 @@ const createSurveysTable = createTableIfNotExists("surveys", function (table) {
|
||||
table.uuid("ownerId").references("id").inTable("users");
|
||||
|
||||
// What do you currently use for saving things on the web?
|
||||
table.boolean("prevToolsDropbox").defaultTo(false);
|
||||
table.boolean("prevToolsArena").defaultTo(false);
|
||||
table.boolean("prevToolsPinterest").defaultTo(false);
|
||||
table.boolean("prevToolsGoogleDrive").defaultTo(false);
|
||||
table.boolean("prevToolsBrowserBookmarks").defaultTo(false);
|
||||
table.boolean("prevToolsPinterest").defaultTo(false);
|
||||
table.boolean("prevToolsArena").defaultTo(false);
|
||||
table.boolean("prevToolsNotesPlatform").defaultTo(false);
|
||||
table.string("prevToolsOther").defaultTo(null);
|
||||
|
||||
// What are you interested in using Slate for?
|
||||
table.boolean("useCasesPersonalStorage").defaultTo(false);
|
||||
table.boolean("useCasesPublicFileSharing").defaultTo(false);
|
||||
table.boolean("useCasesArchiving").defaultTo(false);
|
||||
table.boolean("useCasesBookmarking").defaultTo(false);
|
||||
table.boolean("useCasesMoodboarding").defaultTo(false);
|
||||
table.boolean("useCasesBookmarkingImportantPages").defaultTo(false);
|
||||
table.boolean("useCasesSavingLinksToReadLater").defaultTo(false);
|
||||
table.boolean("useCasesSearchingYourBrowsedPages").defaultTo(false);
|
||||
table.boolean("useCasesSharingCollectionsOfLinks").defaultTo(false);
|
||||
table.string("useCasesOther").defaultTo(null);
|
||||
|
||||
// How did you find out about Slate?
|
||||
|
Loading…
Reference in New Issue
Block a user