# Deployment Guide for Filamenteka ## Important: API Update Required The production API at api.filamenteka.rs needs to be updated with the latest code changes. ### Changes that need to be deployed: 1. **Database Schema Changes**: - Column renamed from `vakum` to `spulna` - Column `otvoreno` has been removed - Data types changed from strings to integers for `refill` and `spulna` - Added CHECK constraint: `kolicina = refill + spulna` 2. **API Server Changes**: - Updated `/api/filaments` endpoints to use new column names - Updated data type handling (integers instead of strings) - Added proper quantity calculation ### Deployment Steps: 1. **Update the API server code**: ```bash # On the production server cd /path/to/api git pull origin main npm install ``` 2. **Run database migrations**: ```bash # Run the migration to rename columns psql $DATABASE_URL < database/migrations/003_rename_vakum_to_spulna.sql # Run the migration to fix data types psql $DATABASE_URL < database/migrations/004_fix_inventory_data_types.sql # Fix any data inconsistencies psql $DATABASE_URL < database/migrations/fix_quantity_consistency.sql ``` 3. **Restart the API server**: ```bash # Restart the service pm2 restart filamenteka-api # or systemctl restart filamenteka-api ``` ### Temporary Frontend Compatibility The frontend has been updated to handle both old and new API response formats, so it will work with both: - Old format: `vakum`, `otvoreno` (strings) - New format: `spulna` (integer), no `otvoreno` field Once the API is updated, the compatibility layer can be removed. ### Verification After deployment, verify: 1. API returns `spulna` instead of `vakum` 2. Values are integers, not strings 3. Quantity calculations are correct (`kolicina = refill + spulna`)