update marketing
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 5m14s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 17s
Build, Push and Deploy / deploy-staging (push) Successful in 41s
Build, Push and Deploy / deploy-production (push) Has been skipped

This commit is contained in:
2026-05-14 11:55:22 +07:00
parent f80fcc4c1b
commit 05fd3230b8
448 changed files with 17545 additions and 5128 deletions

View File

@@ -0,0 +1,30 @@
# Resolved PostgreSQL Migration Errors
I have fixed the issues preventing the application from loading business data and encountering SQL errors after the PostgreSQL migration.
## Changes Made
### 1. `BusinessController` Compatibility
- **Issue**: The application failed with a 500 error when the `superadmin` user logged in because their `business_id` was `null`.
- **Fix**: Updated `app/Http/Controllers/Api/BusinessController.php` to handle `null` business IDs. It now safely falls back to the first available business for users without a specific ID (like superadmins).
- **Benefit**: Fixes the "Failed to fetch business data" error on the dashboard.
### 2. SQL Syntax Fixes
- **Issue**: Use of MySQL-specific `SET FOREIGN_KEY_CHECKS` in seeders caused errors in PostgreSQL.
- **Fix**: Updated `database/seeders/InitialDataSeeder.php` to use database-agnostic `Schema::disableForeignKeyConstraints()`. It also retains PostgreSQL-specific `SET session_replication_role = 'replica'` for full compatibility.
- **Benefit**: Ensures migrations and seeders run correctly on both MySQL and PostgreSQL.
### 3. Syntax Case-Sensitivity & Null Guards
- Refined the business settings logic in `BusinessController` to avoid "Trying to access array offset on value of type null" when a business has no specific options configured.
## Verification Results
### Automated Tests
- Ran `php -l` on modified files:
- `app/Http/Controllers/Api/BusinessController.php`: **Passed**
- `database/seeders/InitialDataSeeder.php`: **Passed**
### Manual Verification Steps (Recommended)
1. Log in as `superadmin@superadmin.com`.
2. Verify that the dashboard loads without the "Failed to fetch business data" error.
3. Review the logs (`storage/logs/laravel.log`) to ensure no new SQL errors are being generated.