Files
bilety.brzezovka.pl/upgrade.php
Jacek Pyziak 238c9ecaed Add initial files and database migration for ticket pricing system
- Created new directories and index files for controls, factory, and views.
- Added .htaccess files for URL rewriting in layout and images directories.
- Included a logo image in the layout/images directory.
- Implemented load_prices.php to load ticket prices from the database into settings.
- Developed admin panel settings page for enabling ticket sales.
- Created tickets management page in the admin panel to display and edit ticket prices.
- Added upgrade.php for database migrations, including creating the ticket_prices table and adding weekend price column.
2026-02-23 00:17:46 +01:00

50 lines
1.4 KiB
PHP

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
header('Content-Type: text/plain; charset=utf-8');
require_once 'config.php';
require_once 'libraries/medoo/medoo.php';
$mdb = new medoo([
'database_type' => 'mysql',
'database_name' => $database['name'],
'server' => $database['host'],
'username' => $database['user'],
'password' => $database['password'],
'charset' => 'utf8'
]);
$migrations = [
'ticket_prices' => "CREATE TABLE IF NOT EXISTS ticket_prices (
ticket_id VARCHAR(100) PRIMARY KEY,
price DECIMAL(10,2) DEFAULT NULL,
price_weekend DECIMAL(10,2) DEFAULT NULL,
dynamic_price_day0 DECIMAL(10,2) DEFAULT NULL,
dynamic_price_day1_2 DECIMAL(10,2) DEFAULT NULL,
dynamic_price_day3_7 DECIMAL(10,2) DEFAULT NULL,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8",
'ticket_prices_add_price_weekend' => "ALTER TABLE ticket_prices ADD COLUMN IF NOT EXISTS price_weekend DECIMAL(10,2) DEFAULT NULL AFTER price",
];
$ok = 0;
$errors = 0;
foreach ($migrations as $name => $sql) {
$result = $mdb->query($sql);
if ($result !== false) {
echo "[OK] $name\n";
$ok++;
} else {
$err = $mdb->error();
echo "[BLAD] $name: " . (is_array($err) ? end($err) : $err) . "\n";
$errors++;
}
}
echo "\nGotowe: $ok OK, $errors bledow.\n";