Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DB *pgxpool.Pool
DB stores the connection pool (pgxpool.Pool). It is used throughout the application to interact with the PostgreSQL database. The pool is created when the Connect function is called.
Functions ¶
func Connect ¶
func Connect()
Connect establishes a connection to the PostgreSQL database using environment variables. It also executes any necessary migrations to ensure required tables exist in the database.
func RunMigrations ¶
func RunMigrations()
RunMigrations executes the database migration process by reading SQL commands from a migration file and applying them to the database. It logs the progress and any errors encountered during the process.
The function performs the following steps: 1. Reads the migration SQL file located at "./src/database/migrations.sql". 2. Executes the SQL commands in the migration file against the database. 3. Logs debug, error, and informational messages to indicate the status of the migration.
If an error occurs while reading the migration file or executing the SQL commands, the error is logged, and the function continues execution.
Types ¶
This section is empty.