-- Lane Guide - Phase 1 Migration
-- Run this in phpMyAdmin or via: mysql -u root -p laneguide < database/migrations/001_create_users_table.sql

CREATE DATABASE IF NOT EXISTS laneguide CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
USE laneguide;

CREATE TABLE IF NOT EXISTS users (
    id                      INT PRIMARY KEY AUTO_INCREMENT,
    email                   VARCHAR(255) UNIQUE NOT NULL,
    password_hash           VARCHAR(255) NOT NULL,
    first_name              VARCHAR(100),
    last_name               VARCHAR(100),
    company                 VARCHAR(255),
    phone                   VARCHAR(50),
    reset_token             VARCHAR(64)  DEFAULT NULL,
    reset_token_expires_at  DATETIME     DEFAULT NULL,
    is_active               BOOLEAN      DEFAULT TRUE,
    last_login              DATETIME     DEFAULT NULL,
    created_at              TIMESTAMP    DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Index for password reset lookups
CREATE INDEX idx_reset_token ON users (reset_token);
