Split API and frontend, migrate SQLite to PostgreSQL

- api.fahrschultermin.de: full API entry point with CORS + session auth
- fahrschultermin.de: frontend only, no more /api/v1 routing
- Database.php: PostgreSQL support (pgsql driver + lastval())
- All repositories: use Database::lastInsertId() for PG compatibility
- config/app.php: PostgreSQL connection settings + CORS config
- bootstrap.php: pass full $config to Database::configure()
- public/index.php: fetch-patch to redirect /api/v1 to api.fahrschultermin.de
- database/schema_pgsql.sql: full PostgreSQL schema (BIGSERIAL)
- database/import_pgsql.sql: 518 rows migrated from SQLite
This commit is contained in:
Hermes Agent
2026-05-18 23:49:42 +02:00
parent 33d61c2fc7
commit 2d6c0ad3aa
15 changed files with 930 additions and 89 deletions

View File

@@ -84,7 +84,7 @@ final class AppointmentRepository extends BaseRepository
'updated_at' => $timestamp,
]);
$appointmentId = (int) $this->db->lastInsertId();
$appointmentId = (int) $this->lastInsertId();
$this->replaceUnits($appointmentId, $data['units_breakdown'] ?? []);
return $this->find($tenantId, $appointmentId);

View File

@@ -16,6 +16,11 @@ abstract class BaseRepository
$this->db = Database::connection();
}
protected function lastInsertId(): string
{
return Database::lastInsertId();
}
protected function now(): string
{
return gmdate('c');

View File

@@ -45,7 +45,7 @@ final class InstructorRepository extends BaseRepository
'updated_at' => $timestamp,
]);
return $this->find($tenantId, (int) $this->db->lastInsertId());
return $this->find($tenantId, (int) $this->lastInsertId());
}
public function update(int $tenantId, int $id, array $data): ?array

View File

@@ -66,7 +66,7 @@ final class ReferenceDataRepository extends BaseRepository
'created_at' => $timestamp,
'updated_at' => $timestamp,
]);
$lessonTypeId = (int) $this->db->lastInsertId();
$lessonTypeId = (int) $this->lastInsertId();
$this->replaceLessonTypeVisibility($tenantId, $lessonTypeId, $data['visible_template_ids'] ?? null);
return $this->findLessonType($tenantId, $lessonTypeId);
@@ -225,7 +225,7 @@ final class ReferenceDataRepository extends BaseRepository
'created_at' => $timestamp,
'updated_at' => $timestamp,
]);
$templateId = (int) $this->db->lastInsertId();
$templateId = (int) $this->lastInsertId();
$this->replaceTemplateRequirements($templateId, $data['requirements'] ?? []);
$this->attachTemplateToExistingStudentLessonTypes($tenantId, $templateId);

View File

@@ -60,7 +60,7 @@ final class StudentRepository extends BaseRepository
'updated_at' => $timestamp,
]);
$studentId = (int) $this->db->lastInsertId();
$studentId = (int) $this->lastInsertId();
$this->snapshotRequirements($studentId, (int) $data['template_id']);
return $this->find($tenantId, $studentId);

View File

@@ -40,7 +40,7 @@ final class TenantRepository extends BaseRepository
'updated_at' => $timestamp,
]);
return $this->find((int) $this->db->lastInsertId());
return $this->find((int) $this->lastInsertId());
}
public function update(int $id, array $data): ?array

View File

@@ -74,7 +74,7 @@ final class UserRepository extends BaseRepository
'updated_at' => $timestamp,
]);
return $this->findById((int) $this->db->lastInsertId());
return $this->findById((int) $this->lastInsertId());
}
public function update(int $id, array $data): ?array