36 lines
1.3 KiB
JavaScript
36 lines
1.3 KiB
JavaScript
import db from './src/lib/db.js';
|
|
|
|
console.log('Starting migration to add wartosc_zlecenia field to projects table...');
|
|
|
|
try {
|
|
// Check if wartosc_zlecenia column already exists
|
|
const schema = db.prepare("PRAGMA table_info(projects)").all();
|
|
const hasWartoscZleceniaColumn = schema.some(column => column.name === 'wartosc_zlecenia');
|
|
|
|
if (hasWartoscZleceniaColumn) {
|
|
console.log("✅ wartosc_zlecenia column already exists in projects table");
|
|
} else {
|
|
// Add the wartosc_zlecenia column
|
|
db.prepare("ALTER TABLE projects ADD COLUMN wartosc_zlecenia REAL").run();
|
|
console.log("✅ Added 'wartosc_zlecenia' column to projects table");
|
|
}
|
|
|
|
// Verify the column was added
|
|
const updatedSchema = db.prepare("PRAGMA table_info(projects)").all();
|
|
const wartoscZleceniaColumn = updatedSchema.find(column => column.name === 'wartosc_zlecenia');
|
|
|
|
if (wartoscZleceniaColumn) {
|
|
console.log("✅ Migration completed successfully");
|
|
console.log(`Column details: ${JSON.stringify(wartoscZleceniaColumn, null, 2)}`);
|
|
} else {
|
|
console.error("❌ Migration failed - wartosc_zlecenia column not found");
|
|
process.exit(1);
|
|
}
|
|
|
|
db.close();
|
|
console.log("Database connection closed");
|
|
|
|
} catch (error) {
|
|
console.error("❌ Migration failed:", error.message);
|
|
process.exit(1);
|
|
} |