Files
gitea-mirror/src/lib/db/migrations/add-mirrored-location.ts
2025-05-18 09:31:23 +05:30

28 lines
939 B
TypeScript

import { client } from "@/lib/db";
/**
* Migration script to add the mirrored_location column to the repositories table
*/
export async function addMirroredLocationColumn() {
try {
console.log("Starting migration: Adding mirrored_location column to repositories table");
// Check if the column already exists
const tableInfo = await client.execute(`PRAGMA table_info(repositories)`);
const columnExists = tableInfo.rows.some((row: any) => row.name === "mirrored_location");
if (columnExists) {
console.log("Column mirrored_location already exists, skipping migration");
return;
}
// Add the mirrored_location column
await client.execute(`ALTER TABLE repositories ADD COLUMN mirrored_location TEXT DEFAULT ''`);
console.log("Migration completed successfully: mirrored_location column added");
} catch (error) {
console.error("Migration failed:", error);
throw error;
}
}