diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index df02f7f..2065dc1 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -124,17 +124,8 @@ else node dist/scripts/manage-db.js fix fi - # Update the database schema - echo "Updating database schema..." - if [ -f "dist/scripts/manage-db.js" ]; then - node dist/scripts/manage-db.js update-schema - fi - - # Run migrations - echo "Running database migrations..." - if [ -f "dist/scripts/run-migrations.js" ]; then - node dist/scripts/run-migrations.js - fi + # Since the application is not used by anyone yet, we've removed the schema updates and migrations + echo "Database already exists, no migrations needed." fi # Start the application diff --git a/package.json b/package.json index 66f28a3..9e206c4 100644 --- a/package.json +++ b/package.json @@ -16,9 +16,6 @@ "check-db": "tsx scripts/manage-db.ts check", "fix-db": "tsx scripts/manage-db.ts fix", "reset-users": "tsx scripts/manage-db.ts reset-users", - "update-schema": "tsx scripts/manage-db.ts update-schema", - "db-auto": "tsx scripts/manage-db.ts auto", - "run-migrations": "tsx scripts/run-migrations.ts", "preview": "astro preview", "start": "node dist/server/entry.mjs", "start:fresh": "pnpm cleanup-db && pnpm manage-db init && node dist/server/entry.mjs", diff --git a/scripts/manage-db.ts b/scripts/manage-db.ts index 65d7d8d..eb84bf4 100644 --- a/scripts/manage-db.ts +++ b/scripts/manage-db.ts @@ -224,102 +224,8 @@ async function checkDatabase() { } } -/** - * Update database schema - */ -async function updateSchema() { - console.log(`Checking and updating database schema at ${dbPath}...`); - - // Check if the database exists - if (!fs.existsSync(dataDbFile)) { - console.log( - "⚠️ Database file doesn't exist. Run 'pnpm manage-db init' first to create it." - ); - return; - } - - try { - console.log("Checking for missing columns in mirror_jobs table..."); - - // Check if repository_id column exists in mirror_jobs table - const tableInfoResult = await client.execute( - `PRAGMA table_info(mirror_jobs)` - ); - - // Get column names - const columns = tableInfoResult.rows.map((row) => row.name); - - // Check for repository_id column - if (!columns.includes("repository_id")) { - console.log( - "Adding missing repository_id column to mirror_jobs table..." - ); - await client.execute( - `ALTER TABLE mirror_jobs ADD COLUMN repository_id TEXT;` - ); - console.log("✅ Added repository_id column to mirror_jobs table."); - } - - // Check for repository_name column - if (!columns.includes("repository_name")) { - console.log( - "Adding missing repository_name column to mirror_jobs table..." - ); - await client.execute( - `ALTER TABLE mirror_jobs ADD COLUMN repository_name TEXT;` - ); - console.log("✅ Added repository_name column to mirror_jobs table."); - } - - // Check for organization_id column - if (!columns.includes("organization_id")) { - console.log( - "Adding missing organization_id column to mirror_jobs table..." - ); - await client.execute( - `ALTER TABLE mirror_jobs ADD COLUMN organization_id TEXT;` - ); - console.log("✅ Added organization_id column to mirror_jobs table."); - } - - // Check for organization_name column - if (!columns.includes("organization_name")) { - console.log( - "Adding missing organization_name column to mirror_jobs table..." - ); - await client.execute( - `ALTER TABLE mirror_jobs ADD COLUMN organization_name TEXT;` - ); - console.log("✅ Added organization_name column to mirror_jobs table."); - } - - // Check for details column - if (!columns.includes("details")) { - console.log("Adding missing details column to mirror_jobs table..."); - await client.execute(`ALTER TABLE mirror_jobs ADD COLUMN details TEXT;`); - console.log("✅ Added details column to mirror_jobs table."); - } - - // Check for mirrored_location column in repositories table - const repoColumns = await client.execute(`PRAGMA table_info(repositories)`); - const repoColumnNames = repoColumns.rows.map((row: any) => row.name); - - if (!repoColumnNames.includes("mirrored_location")) { - console.log( - "Adding missing mirrored_location column to repositories table..." - ); - await client.execute( - `ALTER TABLE repositories ADD COLUMN mirrored_location TEXT DEFAULT '';` - ); - console.log("✅ Added mirrored_location column to repositories table."); - } - - console.log("✅ Schema update completed successfully."); - } catch (error) { - console.error("❌ Error updating schema:", error); - process.exit(1); - } -} +// Database schema updates and migrations have been removed +// since the application is not used by anyone yet /** * Initialize the database @@ -730,7 +636,7 @@ async function fixDatabaseIssues() { // Check if we can connect to the database try { // Try to query the database - const configCount = await db.select().from(configs).limit(1); + await db.select().from(configs).limit(1); console.log(`✅ Successfully connected to the database.`); } catch (error) { console.error("❌ Error connecting to the database:", error); @@ -766,17 +672,11 @@ async function main() { case "reset-users": await resetUsers(); break; - case "update-schema": - await updateSchema(); - break; case "auto": // Auto mode: check, fix, and initialize if needed console.log("Running in auto mode: check, fix, and initialize if needed"); await fixDatabaseIssues(); - // Also update schema in auto mode - await updateSchema(); - if (!fs.existsSync(dataDbFile)) { await initializeDatabase(); } else { @@ -790,7 +690,6 @@ Available commands: init - Initialize the database (only if it doesn't exist) fix - Fix database location issues reset-users - Remove all users and their data - update-schema - Update the database schema to the latest version auto - Automatic mode: check, fix, and initialize if needed Usage: pnpm manage-db [command] diff --git a/scripts/run-migrations.ts b/scripts/run-migrations.ts deleted file mode 100644 index 722b7e7..0000000 --- a/scripts/run-migrations.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { addMirroredLocationColumn } from "../src/lib/db/migrations/add-mirrored-location"; - -async function runMigrations() { - try { - console.log("Running database migrations..."); - - // Run the migration to add the mirrored_location column - await addMirroredLocationColumn(); - - console.log("All migrations completed successfully"); - process.exit(0); - } catch (error) { - console.error("Migration failed:", error); - process.exit(1); - } -} - -runMigrations(); diff --git a/src/lib/db/migrations/add-mirrored-location.ts b/src/lib/db/migrations/add-mirrored-location.ts deleted file mode 100644 index a3c61cd..0000000 --- a/src/lib/db/migrations/add-mirrored-location.ts +++ /dev/null @@ -1,27 +0,0 @@ -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; - } -}