feat: add wartosc_zlecenia field to projects table and update related functionalities

This commit is contained in:
2025-11-14 09:04:46 +01:00
parent 056198ff16
commit 3f87ea16f2
6 changed files with 78 additions and 3 deletions

View File

@@ -0,0 +1,36 @@
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);
}