mirror of
https://github.com/torrentpier/torrentpier
synced 2025-07-05 20:41:41 -07:00
* feat(migrations): implement Phinx database migration system and update installation process - Introduced a modern database migration system using Phinx, replacing the legacy SQL import method. - Updated `install.php` to run migrations instead of importing SQL dumps. - Added migration configuration file `phinx.php` and initial migration files for schema and data seeding. - Created a new admin panel for migration status management. - Updated UPGRADE_GUIDE.md to include migration setup instructions and benefits. - Ensured backward compatibility for existing installations while facilitating a smoother transition to the new system. * update runProcess to return process exit code * refactor(migrations): clean up whitespace and formatting in migration files - Removed unnecessary whitespace and adjusted formatting for consistency across migration files. * fix(migrations): enforce NOT NULL constraints on migration columns - Updated various migration columns to enforce NOT NULL constraints, ensuring data integrity across the schema. - Adjusted default values and nullability for multiple fields in the initial schema migration files. * refactor(database): standardize table engines to InnoDB for reliability - Updated UPGRADE_GUIDE.md to reflect the use of InnoDB for all tables, emphasizing data integrity and reliability. - Modified migration files to change table engines from MyISAM to InnoDB for various tracker and temporary tables. - Optimized session variable settings in cron jobs for InnoDB compatibility. - Ensured consistency across the schema by enforcing InnoDB usage in all relevant areas. * fix(migrations): correct MySQL integer field types to match original schema - Fix bb_forums table: forum_status (INT→TINYINT), forum_tpl_id (INT→SMALLINT) - Fix bb_users table: avatar_ext_id remains TINYINT as per original schema - Fix bb_groups table: avatar_ext_id (SMALLINT→INT) to match original INT(15) - Fix bb_topics table: topic_show_first_post, topic_allow_robots (TINYINT(1)→TINYINT UNSIGNED) - Remove incorrect 'limit' => 11 from standard INT fields, use default Phinx behavior - Fix search_size field to use proper INT type instead of maximum value hack - Correct poll table field types: vote_id (TINYINT), user_id (MEDIUMINT), vote_result (MEDIUMINT UNSIGNED) - Standardize all timestamp and ID fields to use appropriate MySQL integer types Ensures migration creates database schema identical to install/sql/mysql.sql while maintaining InnoDB engine for all tables instead of MyISAM. * fix(cache): auto-create cache directories when using FileStorage The UnifiedCacheSystem was constructing directory paths for Nette FileStorage but not creating them, causing "Directory not found" errors when accessing caches like 'bb_login_err'. FileStorage expects directories to already exist. Changes: - Add automatic directory creation using bb_mkdir() before FileStorage init - Handle both regular cache directories and SQLite parent directories - Apply to both _buildStorage() and _buildDatastoreStorage() methods - Add proper error handling with RuntimeException for failed creation - Maintain consistency with TorrentPier's directory creation patterns This ensures cache directories are created automatically when first accessed, eliminating the need for manual directory creation during deployment. Fixes: Cache initialization failures with missing directories * refactor(docs): update README for clarity and remove legacy SQL file - Improved formatting and clarity in the README, ensuring consistent line breaks and spacing. - Updated installation instructions to reflect the new migration process, emphasizing the use of `phinx` for database setup. - Removed the legacy SQL dump file `mysql.sql` and the `legacy-changes.txt` file, streamlining the installation process and reducing confusion for new users. - Enhanced the documentation to guide users through the setup process more effectively. * docs: enhance CLAUDE.md with migration details and directory updates - Updated the `/library/` section to clarify its purpose. - Added a new `/migrations/` directory section detailing database migration files managed by Phinx. - Included migration commands for running and checking migration status. - Revised the initial schema and seed data references for clarity. - Improved formatting for consistency throughout the document. * refactor(cron): remove demo_mode.php cron job and related functionality - Deleted the demo_mode.php cron job file, which was responsible for managing demo mode operations. - Added a migration to remove the demo_mode.php entry from the bb_cron table, ensuring a clean database state. - Updated the initial schema migration comment to reflect the creation of essential database schema for fresh installations. * refactor(docs): Fixed some typos * chore: update changelog generation starting from v2.4.6-alpha.4 * refactor: Changed some `php_sapi_name()` to `PHP_SAPI` constants * refactor: Extract hardcoded migrations to class property * refactor: Use `count()` to count $initialMigrations elements * feat(migrations): enhance migration management UI with new language variables - Added new language variables for migration status, instructions, and applied/pending migrations to improve user interface clarity. - Updated admin migration template to utilize these new language variables for better localization and maintainability. - Introduced a new file 'CLAUDE.md' to the cleanup process for documentation purposes. --------- Co-authored-by: Roman Kelesidis <roman25052006.kelesh@gmail.com>
74 lines
2.1 KiB
PHP
74 lines
2.1 KiB
PHP
<?php
|
|
/**
|
|
* Phinx configuration for TorrentPier
|
|
*/
|
|
|
|
if (PHP_SAPI != 'cli') {
|
|
die(basename(__FILE__));
|
|
}
|
|
|
|
// Only load what's needed for Phinx - don't bootstrap the entire application
|
|
const BB_ROOT = __DIR__ . DIRECTORY_SEPARATOR;
|
|
const BB_PATH = __DIR__;
|
|
require_once BB_ROOT . 'library/defines.php';
|
|
|
|
// Load environment variables
|
|
use Dotenv\Dotenv;
|
|
|
|
require_once __DIR__ . '/vendor/autoload.php';
|
|
|
|
if (file_exists(__DIR__ . '/.env')) {
|
|
$dotenv = Dotenv::createMutable(__DIR__);
|
|
$dotenv->load();
|
|
}
|
|
|
|
// Helper function for environment variables
|
|
function env(string $key, mixed $default = null): mixed
|
|
{
|
|
$value = $_ENV[$key] ?? getenv($key);
|
|
if ($value === false) {
|
|
return $default;
|
|
}
|
|
return $value;
|
|
}
|
|
|
|
return [
|
|
'paths' => [
|
|
'migrations' => __DIR__ . '/migrations'
|
|
],
|
|
'environments' => [
|
|
'default_migration_table' => BB_MIGRATIONS,
|
|
'default_environment' => env('APP_ENV', 'production'),
|
|
'production' => [
|
|
'adapter' => 'mysql',
|
|
'host' => env('DB_HOST', 'localhost'),
|
|
'port' => (int)env('DB_PORT', 3306),
|
|
'name' => env('DB_DATABASE'),
|
|
'user' => env('DB_USERNAME'),
|
|
'pass' => env('DB_PASSWORD', ''),
|
|
'charset' => 'utf8mb4',
|
|
'collation' => 'utf8mb4_unicode_ci',
|
|
'table_options' => [
|
|
'ENGINE' => 'InnoDB',
|
|
'DEFAULT CHARSET' => 'utf8mb4',
|
|
'COLLATE' => 'utf8mb4_unicode_ci'
|
|
]
|
|
],
|
|
'development' => [
|
|
'adapter' => 'mysql',
|
|
'host' => env('DB_HOST', 'localhost'),
|
|
'port' => (int)env('DB_PORT', 3306),
|
|
'name' => env('DB_DATABASE'),
|
|
'user' => env('DB_USERNAME'),
|
|
'pass' => env('DB_PASSWORD', ''),
|
|
'charset' => 'utf8mb4',
|
|
'collation' => 'utf8mb4_unicode_ci',
|
|
'table_options' => [
|
|
'ENGINE' => 'InnoDB',
|
|
'DEFAULT CHARSET' => 'utf8mb4',
|
|
'COLLATE' => 'utf8mb4_unicode_ci'
|
|
]
|
|
]
|
|
],
|
|
'version_order' => 'creation',
|
|
];
|