Files
open-isp/scripts/migrate-add-ticket-photos.js
T
oxpoe eaf05f2811 OPEN-ISP v0.5 (pickle-lime) — rilis open-source perdana
Aplikasi billing & manajemen ISP (fiber optic) — PWA pelanggan, portal teknisi & kolektor,
admin panel lengkap, multi-vendor OLT, RADIUS, WhatsApp/Telegram, pembayaran QRIS.

Kredit & lisensi (ISC):
- Base kode & repo: alijayanet/billing-rtrw oleh Alijaya Net — terima kasih banyak
  atas base kode dan repo yang bermanfaat.
- Add-on: GoWA, LibreSpeed/OpenSpeedTest, Uptime Kuma, notification-forwarder.
- Dikembangkan menjadi OPEN-ISP oleh oxpoe — https://github.com/oxpoe/open-isp
2026-10-09 05:51:21 +07:00

71 lines
2.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Migration Script: Add Photo Fields to Tickets Table
* Run this once to update existing database
*/
const Database = require('better-sqlite3');
const path = require('path');
const dbPath = path.join(__dirname, '../database/billing.db');
const db = new Database(dbPath);
console.log('🔄 Starting migration: Add photo fields to tickets table...');
try {
// Check if columns already exist
const tableInfo = db.prepare("PRAGMA table_info(tickets)").all();
const columnNames = tableInfo.map(col => col.name);
const hasNotes = columnNames.includes('technician_notes');
const hasPhotos = columnNames.includes('photos');
const hasMetadata = columnNames.includes('photo_metadata');
const hasCustomerPhotos = columnNames.includes('customer_photos');
const hasCustomerMetadata = columnNames.includes('customer_photo_metadata');
if (hasNotes && hasPhotos && hasMetadata && hasCustomerPhotos && hasCustomerMetadata) {
console.log('✅ Migration already applied. All columns exist.');
process.exit(0);
}
// Add columns if they don't exist
if (!hasNotes) {
console.log('➕ Adding column: technician_notes');
db.exec("ALTER TABLE tickets ADD COLUMN technician_notes TEXT DEFAULT ''");
}
if (!hasPhotos) {
console.log('➕ Adding column: photos');
db.exec("ALTER TABLE tickets ADD COLUMN photos TEXT DEFAULT ''");
}
if (!hasMetadata) {
console.log('➕ Adding column: photo_metadata');
db.exec("ALTER TABLE tickets ADD COLUMN photo_metadata TEXT DEFAULT ''");
}
if (!hasCustomerPhotos) {
console.log('➕ Adding column: customer_photos');
db.exec("ALTER TABLE tickets ADD COLUMN customer_photos TEXT DEFAULT ''");
}
if (!hasCustomerMetadata) {
console.log('➕ Adding column: customer_photo_metadata');
db.exec("ALTER TABLE tickets ADD COLUMN customer_photo_metadata TEXT DEFAULT ''");
}
console.log('✅ Migration completed successfully!');
console.log('');
console.log('New columns added:');
console.log(' - technician_notes: Catatan teknisi saat menyelesaikan tugas');
console.log(' - photos: JSON array path foto yang diupload teknisi');
console.log(' - photo_metadata: JSON array metadata foto teknisi (timestamp, GPS, dll)');
console.log(' - customer_photos: JSON array path foto yang diupload pelanggan');
console.log(' - customer_photo_metadata: JSON array metadata foto pelanggan');
} catch (error) {
console.error('❌ Migration failed:', error.message);
process.exit(1);
} finally {
db.close();
}