The toc-schedule application has been migrated from SQLite to MySQL to work with XAMPP. This document explains the setup and configuration.
-
XAMPP installed and running
- Apache service started
- MySQL service started
-
Database created in MySQL
- Run the SQL script:
database_mysql_setup.sql - See
XAMPP_DATABASE_SETUP.mdfor detailed instructions
- Run the SQL script:
Create a .env.local file in the project root with the following content:
DB_TYPE=mysql
DB_HOST=localhost
DB_PORT=3306
DB_USER=root
DB_PASSWORD=
DB_NAME=toc_scheduleNote: The
.env.localfile is gitignored and will not be committed to version control.
The default configuration above works with a standard XAMPP installation:
- Host: localhost
- Port: 3306 (MySQL default)
- User: root
- Password: (empty by default in XAMPP)
- Database: toc_schedule
-
Ensure XAMPP MySQL is running
# Check in XAMPP Control Panel that MySQL shows "Running" -
Install dependencies (if not already done)
npm install
-
Start the development server
npm run dev
-
Access the application
- Open browser to
http://localhost:3000
- Open browser to
- Package: Changed from
better-sqlite3tomysql2 - API: All database calls are now async/await
- Connection: Uses connection pooling instead of single file
SQLite error codes have been replaced with MySQL equivalents:
SQLITE_CONSTRAINT_UNIQUE→ER_DUP_ENTRYSQLITE_CONSTRAINT_FOREIGNKEY→ER_ROW_IS_REFERENCED_2
- Table names wrapped in backticks:
`count`,`Drivers` lastInsertRowid→insertIdchanges→affectedRowsdate('now')→CURDATE()- Prepared statements use
execute()with parameter arrays
- Verify MySQL is running in XAMPP Control Panel
- Check
.env.localfile exists and has correct credentials - Ensure
toc_scheduledatabase exists in phpMyAdmin
- Run the
database_mysql_setup.sqlscript in phpMyAdmin - Verify all tables were created successfully
- Check DB_USER and DB_PASSWORD in
.env.local - Default XAMPP has user
rootwith no password
- Another MySQL instance may be running
- Change DB_PORT in
.env.localor stop other MySQL services
- URL:
http://localhost/phpmyadmin - Username:
root - Password: (leave empty)
-- In phpMyAdmin, select toc_schedule database
-- Click "Export" tab
-- Choose "Quick" export method
-- Click "Export" button-- Run the database_mysql_setup.sql script again
-- This will DROP and recreate the database with fresh data- All API routes have been updated to use async/await
- Connection pooling is configured with 10 max connections
- Foreign key constraints are enforced
- All original functionality is preserved