fix: PostgreSQL insert compatibility issues
Mirror to GitHub (Archive Method) / mirror (push) Failing after 17s
Mirror to GitHub (Rsync Method) / mirror (push) Failing after 17s
Mirror to GitHub / mirror (push) Failing after 19s
Test and Lint / backend-test (push) Successful in 1m7s
Test and Lint / frontend-test (push) Successful in 2m11s
continuous-integration/drone/push Build is passing
Version and Release / version-bump (push) Successful in 35s
Version and Release / trigger-drone (push) Successful in 3s

- Fix event creation failing with 'not iterable' error
- Add .returning('id') to insert queries for PostgreSQL
- Handle both PostgreSQL (returns objects) and SQLite (returns IDs)
- Add missing fields to email_queue insert

This fixes the 500 error when creating new events in production.
This commit is contained in:
2025-07-14 20:31:40 +02:00
parent 2efc74a687
commit f05ad87602
3 changed files with 12 additions and 71 deletions
-66
View File
@@ -1,66 +0,0 @@
# Changelog
All notable changes to PicPeak will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
- Gitea workflows for selective GitHub mirroring
- Password visibility toggle on event creation form
- Translation for password requirement errors
### Changed
- Relaxed password requirements from 12 to 8 characters minimum
- Made special characters optional for gallery passwords
- Improved password strength requirements for better usability
### Fixed
- Production deployment issues with Traefik routing
- Database migration failures for email_queue table
- JSON parsing errors in production environment
- PostgreSQL compatibility issues
- Connection stability in production
## [1.0.22] - 2024-01-14
### Added
- Comprehensive error boundaries for better error handling
- Skeleton loading screens for improved perceived performance
- Offline indicator for network status
- Keyboard navigation support in gallery lightbox
- Skip links for accessibility
- Focus trap management for modals
### Changed
- Improved accessibility to WCAG 2.1 AA compliance
- Enhanced loading states with skeleton screens
- Better error recovery with component-level boundaries
### Fixed
- Missing translations in German locale
- Session timeout caching issues
- Email template JSON parsing errors
## [1.0.0] - 2024-01-01
### Added
- Initial release of PicPeak
- Photo gallery management system
- Automatic file watching and gallery creation
- Password-protected galleries
- Expiration system with email notifications
- Admin dashboard with analytics
- Multi-language support (EN, DE)
- Docker deployment support
- Email template customization
- User upload functionality
- Bulk download features
- Mobile-responsive design
- Theme customization options
[Unreleased]: https://github.com/the-luap/picpeak/compare/v1.0.22...HEAD
[1.0.22]: https://github.com/the-luap/picpeak/compare/v1.0.0...v1.0.22
[1.0.0]: https://github.com/the-luap/picpeak/releases/tag/v1.0.0
+4 -2
View File
@@ -77,12 +77,14 @@ router.post('/', adminAuth, [
}
// Create category
const [categoryId] = await db('photo_categories').insert({
const insertResult = await db('photo_categories').insert({
name,
slug: categorySlug,
is_global,
event_id: is_global ? null : event_id
});
}).returning('id');
const categoryId = insertResult[0]?.id || insertResult[0];
const category = await db('photo_categories').where('id', categoryId).first();
+8 -3
View File
@@ -92,7 +92,7 @@ router.post('/', adminAuth, [
await fs.mkdir(path.join(eventPath, 'individual'), { recursive: true });
// Insert into database
const [eventId] = await db('events').insert({
const insertResult = await db('events').insert({
slug,
event_type,
event_name,
@@ -108,7 +108,10 @@ router.post('/', adminAuth, [
created_at: new Date().toISOString(),
allow_user_uploads,
upload_category_id
});
}).returning('id');
// Handle both PostgreSQL (returns array of objects) and SQLite (returns array of IDs)
const eventId = insertResult[0]?.id || insertResult[0];
// Log activity
await logActivity('event_created',
@@ -133,7 +136,9 @@ router.post('/', adminAuth, [
gallery_password: password,
expiry_date: await formatDate(expires_at, emailLang),
welcome_message: welcome_message || ''
})
}),
status: 'pending',
created_at: new Date()
// scheduled_at will use default value
});