<?php
/**
 * Migration Runner: Create Stock Taking Tables
 * Run this script to create the stock_takings and stock_taking_items tables
 */

require_once __DIR__ . '/config/config.php';
require_once __DIR__ . '/config/database.php';

echo "Running Stock Taking Migration...\n";

try {
    $sql = file_get_contents(__DIR__ . '/database/migrations/create_stock_taking_tables.sql');
    
    if ($sql === false) {
        die("Error: Could not read migration file.\n");
    }
    
    $db = db();
    $db->exec($sql);
    
    echo "✓ Stock taking tables created successfully!\n";
    echo "✓ Tables: stock_takings, stock_taking_items\n";
    
} catch (PDOException $e) {
    echo "✗ Migration failed: " . $e->getMessage() . "\n";
    exit(1);
}

echo "\nMigration complete!\n";
