feat: add wartosc_zlecenia field to projects table and update related functionalities
This commit is contained in:
36
migrate-add-wartosc-zlecenia.mjs
Normal file
36
migrate-add-wartosc-zlecenia.mjs
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user