Tracking expense RR
This commit is contained in:
parent
203b8f157b
commit
b92ba614bb
35
assets/css/custom.css
Normal file
35
assets/css/custom.css
Normal file
@ -0,0 +1,35 @@
|
||||
body {
|
||||
background-color: #f8f9fa;
|
||||
}
|
||||
|
||||
.card {
|
||||
border: none;
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background-color: #0d6efd;
|
||||
border-color: #0d6efd;
|
||||
}
|
||||
|
||||
.btn-danger {
|
||||
background-color: #dc3545;
|
||||
border-color: #dc3545;
|
||||
}
|
||||
|
||||
.table {
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.table th {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.toast-header {
|
||||
background-color: #0d6efd;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.toast-body {
|
||||
background-color: white;
|
||||
}
|
||||
149
assets/js/main.js
Normal file
149
assets/js/main.js
Normal file
@ -0,0 +1,149 @@
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const initialBalanceEl = document.getElementById('initialBalance');
|
||||
const currentBalanceEl = document.getElementById('currentBalance');
|
||||
const transactionHistoryEl = document.getElementById('transactionHistory');
|
||||
const incomeForm = document.getElementById('incomeForm');
|
||||
const expenseForm = document.getElementById('expenseForm');
|
||||
const incomeModal = new bootstrap.Modal(document.getElementById('incomeModal'));
|
||||
const expenseModal = new bootstrap.Modal(document.getElementById('expenseModal'));
|
||||
const toastEl = document.getElementById('liveToast');
|
||||
const toast = new bootstrap.Toast(toastEl);
|
||||
|
||||
// Search elements
|
||||
const startDateEl = document.getElementById('startDate');
|
||||
const endDateEl = document.getElementById('endDate');
|
||||
const searchBtn = document.getElementById('searchBtn');
|
||||
const clearBtn = document.getElementById('clearBtn');
|
||||
|
||||
let transactions = JSON.parse(localStorage.getItem('transactions')) || [];
|
||||
let initialBalance = parseFloat(localStorage.getItem('initialBalance')) || 0;
|
||||
|
||||
initialBalanceEl.value = initialBalance;
|
||||
|
||||
const formatCurrency = (amount) => {
|
||||
return new Intl.NumberFormat('en-IN', { style: 'currency', currency: 'INR' }).format(amount);
|
||||
};
|
||||
|
||||
const showToast = (message, type) => {
|
||||
const toastBody = toastEl.querySelector('.toast-body');
|
||||
const toastHeader = toastEl.querySelector('.toast-header');
|
||||
toastBody.textContent = message;
|
||||
toastHeader.classList.remove('bg-success', 'bg-danger');
|
||||
toastHeader.classList.add(type === 'success' ? 'bg-success' : 'bg-danger');
|
||||
toast.show();
|
||||
};
|
||||
|
||||
const renderTransactions = (transactionsToRender) => {
|
||||
transactionHistoryEl.innerHTML = '';
|
||||
let balance = initialBalance;
|
||||
transactions.forEach(t => balance += t.amount);
|
||||
|
||||
if (transactionsToRender.length === 0) {
|
||||
transactionHistoryEl.innerHTML = '<tr><td colspan="5" class="text-center text-muted">No transactions found for this period.</td></tr>';
|
||||
} else {
|
||||
transactionsToRender.slice().reverse().forEach(transaction => {
|
||||
const row = document.createElement('tr');
|
||||
const typeClass = transaction.amount > 0 ? 'text-success' : 'text-danger';
|
||||
row.innerHTML = `
|
||||
<td>${new Date(transaction.date).toLocaleDateString()}</td>
|
||||
<td><span class="badge bg-${transaction.amount > 0 ? 'success' : 'danger'}">${transaction.amount > 0 ? 'Income' : 'Expense'}</span></td>
|
||||
<td>${transaction.description}</td>
|
||||
<td class="text-end fw-bold ${typeClass}">${formatCurrency(transaction.amount)}</td>
|
||||
<td><button class="btn btn-sm btn-outline-danger delete-btn" data-id="${transaction.id}"><i class="bi bi-trash"></i></button></td>
|
||||
`;
|
||||
transactionHistoryEl.appendChild(row);
|
||||
});
|
||||
}
|
||||
|
||||
currentBalanceEl.textContent = formatCurrency(balance);
|
||||
};
|
||||
|
||||
const addTransaction = (amount, description, date) => {
|
||||
const transaction = {
|
||||
id: Date.now(),
|
||||
date: date || new Date().toISOString().split('T')[0],
|
||||
amount: amount,
|
||||
description: description
|
||||
};
|
||||
transactions.push(transaction);
|
||||
localStorage.setItem('transactions', JSON.stringify(transactions));
|
||||
renderTransactions(transactions);
|
||||
};
|
||||
|
||||
const deleteTransaction = (id) => {
|
||||
transactions = transactions.filter(t => t.id !== id);
|
||||
localStorage.setItem('transactions', JSON.stringify(transactions));
|
||||
renderTransactions(transactions);
|
||||
showToast('Transaction deleted successfully!', 'success');
|
||||
};
|
||||
|
||||
transactionHistoryEl.addEventListener('click', (e) => {
|
||||
if (e.target.closest('.delete-btn')) {
|
||||
const id = parseInt(e.target.closest('.delete-btn').dataset.id);
|
||||
deleteTransaction(id);
|
||||
}
|
||||
});
|
||||
|
||||
initialBalanceEl.addEventListener('input', (e) => {
|
||||
initialBalance = parseFloat(e.target.value) || 0;
|
||||
localStorage.setItem('initialBalance', initialBalance);
|
||||
renderTransactions(transactions);
|
||||
});
|
||||
|
||||
incomeForm.addEventListener('submit', (e) => {
|
||||
e.preventDefault();
|
||||
const amount = parseFloat(document.getElementById('incomeAmount').value);
|
||||
const description = document.getElementById('incomeDescription').value;
|
||||
const date = document.getElementById('incomeDate').value;
|
||||
if (amount > 0 && description && date) {
|
||||
addTransaction(amount, description, date);
|
||||
showToast('Income added successfully!', 'success');
|
||||
incomeForm.reset();
|
||||
document.getElementById('incomeDate').valueAsDate = new Date();
|
||||
incomeModal.hide();
|
||||
} else {
|
||||
showToast('Please enter a valid amount, description, and date.', 'danger');
|
||||
}
|
||||
});
|
||||
|
||||
expenseForm.addEventListener('submit', (e) => {
|
||||
e.preventDefault();
|
||||
const amount = parseFloat(document.getElementById('expenseAmount').value);
|
||||
const description = document.getElementById('expenseDescription').value;
|
||||
const date = document.getElementById('expenseDate').value;
|
||||
if (amount > 0 && description && date) {
|
||||
addTransaction(-amount, description, date);
|
||||
showToast('Expense added successfully!', 'success');
|
||||
expenseForm.reset();
|
||||
document.getElementById('expenseDate').valueAsDate = new Date();
|
||||
expenseModal.hide();
|
||||
} else {
|
||||
showToast('Please enter a valid amount, description, and date.', 'danger');
|
||||
}
|
||||
});
|
||||
|
||||
searchBtn.addEventListener('click', () => {
|
||||
const startDate = startDateEl.value;
|
||||
const endDate = endDateEl.value;
|
||||
|
||||
if (!startDate || !endDate) {
|
||||
showToast('Please select both a start and end date.', 'danger');
|
||||
return;
|
||||
}
|
||||
|
||||
const filteredTransactions = transactions.filter(t => {
|
||||
const transactionDate = t.date;
|
||||
return transactionDate >= startDate && transactionDate <= endDate;
|
||||
});
|
||||
|
||||
renderTransactions(filteredTransactions);
|
||||
});
|
||||
|
||||
clearBtn.addEventListener('click', () => {
|
||||
startDateEl.value = '';
|
||||
endDateEl.value = '';
|
||||
renderTransactions(transactions);
|
||||
});
|
||||
|
||||
renderTransactions(transactions);
|
||||
});
|
||||
16
db/migrations/001_create_tables.sql
Normal file
16
db/migrations/001_create_tables.sql
Normal file
@ -0,0 +1,16 @@
|
||||
CREATE TABLE IF NOT EXISTS `users` (
|
||||
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||
`username` VARCHAR(50) NOT NULL UNIQUE,
|
||||
`password` VARCHAR(255) NOT NULL,
|
||||
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `transactions` (
|
||||
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||
`user_id` INT NOT NULL,
|
||||
`description` VARCHAR(255) NOT NULL,
|
||||
`amount` DECIMAL(10, 2) NOT NULL,
|
||||
`type` ENUM('income', 'expense') NOT NULL,
|
||||
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
296
index.php
296
index.php
@ -1,150 +1,160 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
@ini_set('display_errors', '1');
|
||||
@error_reporting(E_ALL);
|
||||
@date_default_timezone_set('UTC');
|
||||
|
||||
$phpVersion = PHP_VERSION;
|
||||
$now = date('Y-m-d H:i:s');
|
||||
?>
|
||||
<!doctype html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>New Style</title>
|
||||
<?php
|
||||
// Read project preview data from environment
|
||||
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
|
||||
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
||||
?>
|
||||
<?php if ($projectDescription): ?>
|
||||
<!-- Meta description -->
|
||||
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
|
||||
<!-- Open Graph meta tags -->
|
||||
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<!-- Twitter meta tags -->
|
||||
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<?php endif; ?>
|
||||
<?php if ($projectImageUrl): ?>
|
||||
<!-- Open Graph image -->
|
||||
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||
<!-- Twitter image -->
|
||||
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||
<?php endif; ?>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
:root {
|
||||
--bg-color-start: #6a11cb;
|
||||
--bg-color-end: #2575fc;
|
||||
--text-color: #ffffff;
|
||||
--card-bg-color: rgba(255, 255, 255, 0.01);
|
||||
--card-border-color: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: 'Inter', sans-serif;
|
||||
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
|
||||
color: var(--text-color);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
body::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M-10 10L110 10M10 -10L10 110" stroke-width="1" stroke="rgba(255,255,255,0.05)"/></svg>');
|
||||
animation: bg-pan 20s linear infinite;
|
||||
z-index: -1;
|
||||
}
|
||||
@keyframes bg-pan {
|
||||
0% { background-position: 0% 0%; }
|
||||
100% { background-position: 100% 100%; }
|
||||
}
|
||||
main {
|
||||
padding: 2rem;
|
||||
}
|
||||
.card {
|
||||
background: var(--card-bg-color);
|
||||
border: 1px solid var(--card-border-color);
|
||||
border-radius: 16px;
|
||||
padding: 2rem;
|
||||
backdrop-filter: blur(20px);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.loader {
|
||||
margin: 1.25rem auto 1.25rem;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border: 3px solid rgba(255, 255, 255, 0.25);
|
||||
border-top-color: #fff;
|
||||
border-radius: 50%;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
@keyframes spin {
|
||||
from { transform: rotate(0deg); }
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
.hint {
|
||||
opacity: 0.9;
|
||||
}
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px; height: 1px;
|
||||
padding: 0; margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap; border: 0;
|
||||
}
|
||||
h1 {
|
||||
font-size: 3rem;
|
||||
font-weight: 700;
|
||||
margin: 0 0 1rem;
|
||||
letter-spacing: -1px;
|
||||
}
|
||||
p {
|
||||
margin: 0.5rem 0;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
code {
|
||||
background: rgba(0,0,0,0.2);
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
}
|
||||
footer {
|
||||
position: absolute;
|
||||
bottom: 1rem;
|
||||
font-size: 0.8rem;
|
||||
opacity: 0.7;
|
||||
}
|
||||
</style>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Rahul sharma</title>
|
||||
<meta name="description" content="Built with Flatlogic Generator">
|
||||
<meta name="keywords" content="personal finance, budget tracker, expense manager, income calculator, savings tool, money management, financial planning, interactive calculator, Built with Flatlogic Generator">
|
||||
<meta property="og:title" content="Rahul sharma">
|
||||
<meta property="og:description" content="Built with Flatlogic Generator">
|
||||
<meta property="og:image" content="">
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<meta name="twitter:image" content="">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<div class="card">
|
||||
<h1>Analyzing your requirements and generating your website…</h1>
|
||||
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
|
||||
<span class="sr-only">Loading…</span>
|
||||
</div>
|
||||
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
|
||||
<p class="hint">This page will update automatically as the plan is implemented.</p>
|
||||
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
|
||||
|
||||
<main class="container my-5">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-lg-8 col-md-10">
|
||||
<div class="text-center mb-5">
|
||||
<h1 class="fw-bold">Personal Finance Calculator</h1>
|
||||
<p class="lead text-muted">A simple way to track your income and expenses.</p>
|
||||
</div>
|
||||
|
||||
<div class="card shadow-sm mb-4">
|
||||
<div class="card-body p-4 text-center">
|
||||
<div class="mb-3">
|
||||
<label for="initialBalance" class="form-label">Initial Balance</label>
|
||||
<input type="number" class="form-control" id="initialBalance" placeholder="Enter your starting balance">
|
||||
</div>
|
||||
<h6 class="text-muted mb-2">Current Balance</h6>
|
||||
<h2 class="fw-bold" id="currentBalance">₹0.00</h2>
|
||||
<div class="d-flex justify-content-center mt-4">
|
||||
<button class="btn btn-primary me-2" data-bs-toggle="modal" data-bs-target="#incomeModal"><i class="bi bi-plus-circle"></i> Add Income</button>
|
||||
<button class="btn btn-danger" data-bs-toggle="modal" data-bs-target="#expenseModal"><i class="bi bi-dash-circle"></i> Add Expense</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header bg-white">
|
||||
<h5 class="mb-0">Transaction History</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row mb-3 align-items-end">
|
||||
<div class="col-md-4">
|
||||
<label for="startDate" class="form-label">Start Date</label>
|
||||
<input type="date" class="form-control" id="startDate">
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="endDate" class="form-label">End Date</label>
|
||||
<input type="date" class="form-control" id="endDate">
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<button class="btn btn-primary me-2" id="searchBtn">Search</button>
|
||||
<button class="btn btn-secondary" id="clearBtn">Clear</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Date</th>
|
||||
<th scope="col">Type</th>
|
||||
<th scope="col">Description</th>
|
||||
<th scope="col" class="text-end">Amount</th>
|
||||
<th scope="col">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="transactionHistory">
|
||||
<!-- Transactions will be injected here by JavaScript -->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<!-- Income Modal -->
|
||||
<div class="modal fade" id="incomeModal" tabindex="-1" aria-labelledby="incomeModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="incomeModalLabel">Add Income</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="incomeForm">
|
||||
<div class="mb-3">
|
||||
<label for="incomeAmount" class="form-label">Amount</label>
|
||||
<input type="number" class="form-control" id="incomeAmount" placeholder="Enter amount" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="incomeDate" class="form-label">Date</label>
|
||||
<input type="date" class="form-control" id="incomeDate" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="incomeDescription" class="form-label">Description</label>
|
||||
<input type="text" class="form-control" id="incomeDescription" placeholder="e.g., Salary, Freelance work" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary w-100">Add Income</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
Page updated: <?= htmlspecialchars($now) ?> (UTC)
|
||||
</footer>
|
||||
|
||||
<!-- Expense Modal -->
|
||||
<div class="modal fade" id="expenseModal" tabindex="-1" aria-labelledby="expenseModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="expenseModalLabel">Add Expense</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="expenseForm">
|
||||
<div class="mb-3">
|
||||
<label for="expenseAmount" class="form-label">Amount</label>
|
||||
<input type="number" class="form-control" id="expenseAmount" placeholder="Enter amount" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="expenseDate" class="form-label">Date</label>
|
||||
<input type="date" class="form-control" id="expenseDate" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="expenseDescription" class="form-label">Description</label>
|
||||
<input type="text" class="form-control" id="expenseDescription" placeholder="e.g., Groceries, Rent" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-danger w-100">Add Expense</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="position-fixed bottom-0 end-0 p-3" style="z-index: 11">
|
||||
<div id="liveToast" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
|
||||
<div class="toast-header">
|
||||
<strong class="me-auto">Notification</strong>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="toast-body">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
||||
<script>
|
||||
document.getElementById('incomeDate').valueAsDate = new Date();
|
||||
document.getElementById('expenseDate').valueAsDate = new Date();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
28
migrate.php
Normal file
28
migrate.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/db/config.php';
|
||||
|
||||
try {
|
||||
$pdo = db();
|
||||
$migrationsDir = __DIR__ . '/db/migrations';
|
||||
$files = glob($migrationsDir . '/*.sql');
|
||||
|
||||
if (empty($files)) {
|
||||
echo "No migration files found.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
sort($files);
|
||||
|
||||
foreach ($files as $file) {
|
||||
echo "Running migration: " . basename($file) . "...\n";
|
||||
$sql = file_get_contents($file);
|
||||
$pdo->exec($sql);
|
||||
echo "Success.\n";
|
||||
}
|
||||
|
||||
echo "\nAll migrations completed successfully.\n";
|
||||
|
||||
} catch (PDOException $e) {
|
||||
die("Database migration failed: " . $e->getMessage() . "\n");
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user