Merge branch 'active_did_redux' of ssh://173.199.124.46:222/trent_larson/crowd-funder-for-time-pwa into active_did_redux
This commit is contained in:
@@ -595,7 +595,7 @@ export async function runMigrations<T>(
|
||||
try {
|
||||
migrationLog("📋 [Migration] Starting migration process...");
|
||||
|
||||
// Step 1: Create migrations table if it doesn't exist
|
||||
// Create migrations table if it doesn't exist
|
||||
// Note: We use IF NOT EXISTS here because this is infrastructure, not a business migration
|
||||
await sqlExec(`
|
||||
CREATE TABLE IF NOT EXISTS migrations (
|
||||
@@ -604,41 +604,14 @@ export async function runMigrations<T>(
|
||||
);
|
||||
`);
|
||||
|
||||
// Step 2: Handle migration name changes (master branch compatibility)
|
||||
// Map old migration names to new ones
|
||||
const migrationNameMap = new Map([
|
||||
// No longer needed - migrations consolidated into single 003
|
||||
]);
|
||||
|
||||
// Update any old migration names to new ones
|
||||
for (const [oldName, newName] of migrationNameMap) {
|
||||
try {
|
||||
await sqlExec("UPDATE migrations SET name = ? WHERE name = ?", [
|
||||
newName,
|
||||
oldName,
|
||||
]);
|
||||
if (
|
||||
await sqlQuery("SELECT 1 FROM migrations WHERE name = ? LIMIT 1", [
|
||||
newName,
|
||||
])
|
||||
) {
|
||||
migrationLog(
|
||||
`🔄 [Migration] Renamed migration: ${oldName} → ${newName}`,
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
// Ignore errors - migration might not exist
|
||||
}
|
||||
}
|
||||
|
||||
// Step 3: Get list of already applied migrations
|
||||
// Step 2: Get list of already applied migrations
|
||||
const appliedMigrationsResult = await sqlQuery(
|
||||
"SELECT name FROM migrations",
|
||||
);
|
||||
|
||||
const appliedMigrations = extractMigrationNames(appliedMigrationsResult);
|
||||
|
||||
// Step 4: Get all registered migrations
|
||||
// Step 3: Get all registered migrations
|
||||
const migrations = migrationRegistry.getMigrations();
|
||||
|
||||
if (migrations.length === 0) {
|
||||
@@ -653,7 +626,7 @@ export async function runMigrations<T>(
|
||||
let appliedCount = 0;
|
||||
let skippedCount = 0;
|
||||
|
||||
// Step 5: Process each migration
|
||||
// Step 4: Process each migration
|
||||
for (const migration of migrations) {
|
||||
// Check 1: Is it recorded as applied in migrations table?
|
||||
const isRecordedAsApplied = appliedMigrations.has(migration.name);
|
||||
@@ -775,7 +748,7 @@ export async function runMigrations<T>(
|
||||
}
|
||||
}
|
||||
|
||||
// Step 5: Final validation - verify all migrations are properly recorded
|
||||
// Step 6: Final validation - verify all migrations are properly recorded
|
||||
const finalMigrationsResult = await sqlQuery("SELECT name FROM migrations");
|
||||
const finalAppliedMigrations = extractMigrationNames(finalMigrationsResult);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user