-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add remove duplicate script to scripts
- Loading branch information
1 parent
ce7d0dd
commit 2218092
Showing
2 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import "dotenv/config"; | ||
|
||
import postgres from "postgres"; | ||
import { removeDuplicateLinks } from "../server/db/scripts/removeDuplicateLinks.js"; | ||
|
||
// Initialize database connection | ||
if (!process.env.DATABASE_URL) { | ||
console.error("DATABASE_URL is required"); | ||
process.exit(1); | ||
} | ||
|
||
const sql = postgres(process.env.DATABASE_URL, { max: 1 }); | ||
|
||
async function main() { | ||
try { | ||
console.log("Starting duplicate links removal..."); | ||
await removeDuplicateLinks(); | ||
console.log("Completed removing duplicate links"); | ||
} catch (error) { | ||
console.error("Failed to remove duplicate links:", error); | ||
process.exit(1); | ||
} finally { | ||
await sql.end(); | ||
} | ||
} | ||
|
||
// If running as a module | ||
if (import.meta.url === import.meta.resolve(process.argv[1])) { | ||
main().catch((error) => { | ||
console.error("Script failed:", error); | ||
process.exit(1); | ||
}); | ||
} | ||
|
||
export { main as removeDuplicates }; |