diff --git a/main.ts b/main.ts index 14af0c7f4..b90291a01 100644 --- a/main.ts +++ b/main.ts @@ -10,21 +10,4 @@ import { start } from "$fresh/server.ts"; import manifest from "./fresh.gen.ts"; import config from "./fresh.config.ts"; -/** - * @todo Remove at v1. This is a quick way to reset Deno KV, as database changes are likely to occur and require reset. - */ -import { resetKv } from "./tools/reset_kv.ts"; -import { migrateKv } from "./tools/migrate_kv.ts"; - -if (Deno.env.get("RESET_DENO_KV") === "1") { - await resetKv(); -} - -/** - * @todo Remove at v1. This is a quick way to migrate Deno KV, as database changes are likely to occur and require adjustment. - */ -if (Deno.env.get("MIGRATE_DENO_KV") === "1") { - await migrateKv(); -} - await start(manifest, config); diff --git a/tools/migrate_kv.ts b/tools/migrate_kv.ts deleted file mode 100644 index bab914f2c..000000000 --- a/tools/migrate_kv.ts +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2023 the Deno authors. All rights reserved. MIT license. -import { createVote, type Item, kv } from "@/utils/db.ts"; - -interface OldVote { - userLogin: string; - item: Item; - // The below property can be automatically generated upon vote creation - id: string; - createdAt: Date; -} - -/** @todo Remove previous vote data once this migration is complete */ -export async function migrateKv() { - const promises = []; - const iter = kv.list({ prefix: ["votes"] }); - for await (const { value } of iter) { - promises.push(createVote({ - itemId: value.item.id, - userLogin: value.userLogin, - createdAt: value.createdAt, - })); - } - const results = await Promise.allSettled(promises); - const failures = results.filter((result) => result.status === "rejected"); - failures.forEach((result) => console.log(result)); - console.log(`${results.length} total | ${failures.length} failed`); - console.log("KV migration complete"); -} - -if (import.meta.main) { - if ( - !confirm("Would you like to continue?") - ) { - close(); - } - await migrateKv(); - await kv.close(); -}