# Database Configuration Guide

## Current Setup
The application is currently configured to use **SQLite** by default. To switch to **MySQL** or another database, follow these steps:

## Switching to MySQL

### 1. Update `.env` file
Open your `.env` file and update the following database configuration:

```env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=loyal_aid
DB_USERNAME=root
DB_PASSWORD=your_password
```

### 2. Create the Database
Create a MySQL database named `loyal_aid`:

```sql
CREATE DATABASE loyal_aid CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
```

Or via command line:
```bash
mysql -u root -p -e "CREATE DATABASE loyal_aid CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
```

### 3. Run Migrations
After updating your `.env` file, run the migrations:

```bash
php artisan migrate:fresh --seed
```

This will:
- Drop all existing tables
- Create all tables fresh
- Seed initial data (roles, permissions, subscription plans, admin user)

### 4. Clear Configuration Cache
Clear the configuration cache to ensure Laravel picks up the new database settings:

```bash
php artisan config:clear
php artisan cache:clear
```

## Why SQLite?
SQLite is used by default because:
- No server setup required
- Perfect for development and testing
- File-based database (easy to backup)
- Zero configuration needed

## Production Recommendation
For production environments, use **MySQL** or **PostgreSQL** for:
- Better performance with large datasets
- Concurrent user support
- Advanced features (stored procedures, triggers, etc.)
- Better data integrity and security

## Current Database File Location
If using SQLite, the database file is located at:
`database/database.sqlite`

Make sure this file exists and is writable by your web server.

