Add 100+ automated unit tests from .expect file specifications Add session system test Add rsx:constants:regenerate command test Add rsx:logrotate command test Add rsx:clean command test Add rsx:manifest:stats command test Add model enum system test Add model mass assignment prevention test Add rsx:check command test Add migrate:status command test 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
83 lines
2.2 KiB
PHP
83 lines
2.2 KiB
PHP
<?php
|
|
/**
|
|
* CODING CONVENTION:
|
|
* This file follows the coding convention where variable_names and function_names
|
|
* use snake_case (underscore_wherever_possible).
|
|
*/
|
|
|
|
namespace App\RSpade\Core\Database;
|
|
|
|
/**
|
|
* Central location for migration path management
|
|
*
|
|
* RSpade supports migrations in two locations:
|
|
* 1. /database/migrations - Framework and system migrations
|
|
* 2. /rsx/resource/migrations - Application migrations (outside manifest scanning)
|
|
*
|
|
* The /resource/ directory is excluded from manifest scanning, making it suitable
|
|
* for migrations and other framework-related code that doesn't follow RSX conventions.
|
|
*/
|
|
class MigrationPaths
|
|
{
|
|
/**
|
|
* Get all migration directories in order they should be scanned
|
|
*
|
|
* @return array Array of absolute paths to migration directories
|
|
*/
|
|
public static function get_all_paths(): array
|
|
{
|
|
return [
|
|
database_path('migrations'),
|
|
base_path('rsx/resource/migrations'),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get the default path for new migrations created via make:migration:safe
|
|
*
|
|
* @return string Absolute path to default migration directory
|
|
*/
|
|
public static function get_default_path(): string
|
|
{
|
|
return database_path('migrations');
|
|
}
|
|
|
|
/**
|
|
* Ensure all migration directories exist
|
|
*
|
|
* @return void
|
|
*/
|
|
public static function ensure_directories_exist(): void
|
|
{
|
|
foreach (static::get_all_paths() as $path) {
|
|
if (!is_dir($path)) {
|
|
mkdir($path, 0755, true);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get all migration files from all paths, sorted by name (timestamp)
|
|
*
|
|
* @return array Array of absolute file paths
|
|
*/
|
|
public static function get_all_migration_files(): array
|
|
{
|
|
$files = [];
|
|
|
|
foreach (static::get_all_paths() as $path) {
|
|
if (is_dir($path)) {
|
|
$path_files = glob($path . '/*.php');
|
|
if ($path_files) {
|
|
$files = array_merge($files, $path_files);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Sort by filename (timestamp)
|
|
sort($files);
|
|
|
|
return $files;
|
|
}
|
|
}
|