Overview
The Reservations application uses PostgreSQL with the PostGIS extension for geospatial functionality. The database stores merchant locations using geographic points, which requires PostGIS support.Docker-based Setup
The recommended approach is to use Docker with the official PostGIS image, which includes both PostgreSQL and PostGIS pre-configured.Creating the Database
Ensure environment variables are set
Make sure your See the Environment Configuration page for details.
.env file contains the required database configuration:.env
Create the PostgreSQL container
Use the Make command to create and start the PostgreSQL database:This command runs the following Docker command:
The database uses a Docker volume named
pgdata for persistent storage. Your data will be retained even if the container is removed.Managing the Database Container
Database Schema
The application uses a comprehensive schema defined inbackend/internal/repository/schema.sql. Key features include:
PostGIS Extension
The schema enables the PostGIS extension for geospatial support:Custom Types
The schema defines several custom PostgreSQL types:Geospatial Data
TheLocation table uses PostGIS for storing geographic coordinates:
Core Tables
The database includes tables for:- User Management:
User,Employee,Customer - Merchant Data:
Merchant,Location,Preferences - Services:
Service,ServiceCategory,ServicePhase,ServiceProduct - Bookings:
Booking,BookingDetails,BookingParticipant,BookingSeries - Calendar:
BlockedTime,ExternalCalendar,ExternalCalendarEvent - Inventory:
Product - Availability:
BusinessHours
Timezone Configuration
The database is configured to use UTC timezone:Connecting to the Database
You can connect to the database using the PostgreSQL command-line client:Alternative Setup (Non-Docker)
If you prefer not to use Docker, you can install PostgreSQL and PostGIS manually:Install PostgreSQL
Download and install PostgreSQL from postgresql.org
Troubleshooting
Port Already in Use
If port 5432 is already in use, change theDB_PORT in your .env file:
Connection Refused
Ensure the database container is running:PostGIS Extension Not Found
If you see errors about PostGIS, ensure you’re using thepostgis/postgis Docker image, not the standard postgres image.