last version
This commit is contained in:
parent
66989c3877
commit
d746b6aa45
@ -184,6 +184,10 @@ class DatabaseInstaller {
|
||||
glob(__DIR__ . '/../db/migrations/*.php') ?: []
|
||||
);
|
||||
|
||||
$files = array_values(array_filter($files, static function (string $filePath): bool {
|
||||
return !self::isLegacyNumberedMigrationFile($filePath);
|
||||
}));
|
||||
|
||||
usort($files, static function (string $left, string $right): int {
|
||||
return strnatcasecmp(self::migrationSortKey($left), self::migrationSortKey($right));
|
||||
});
|
||||
@ -191,6 +195,12 @@ class DatabaseInstaller {
|
||||
return $files;
|
||||
}
|
||||
|
||||
private static function isLegacyNumberedMigrationFile(string $filePath): bool {
|
||||
// Old packaged builds sometimes carried numeric migrations like 001_*.sql / 002_*.sql
|
||||
// from a legacy orders-based schema. This project now uses date-based migrations instead.
|
||||
return preg_match('/^\d{1,7}_/', basename($filePath)) === 1;
|
||||
}
|
||||
|
||||
private static function migrationSortKey(string $filePath): string {
|
||||
$basename = basename($filePath);
|
||||
|
||||
|
||||
@ -23,12 +23,21 @@ function installationMigrationSortKey(string $filePath): string {
|
||||
};
|
||||
}
|
||||
|
||||
function installationLegacyNumberedMigrationFile(string $filePath): bool {
|
||||
// Skip obsolete pre-date-based migrations from older packaged builds.
|
||||
return preg_match('/^\d{1,7}_/', basename($filePath)) === 1;
|
||||
}
|
||||
|
||||
function installationMigrationFiles(): array {
|
||||
$files = array_merge(
|
||||
glob(__DIR__ . '/../db/migrations/*.sql') ?: [],
|
||||
glob(__DIR__ . '/../db/migrations/*.php') ?: []
|
||||
);
|
||||
|
||||
$files = array_values(array_filter($files, static function (string $filePath): bool {
|
||||
return !installationLegacyNumberedMigrationFile($filePath);
|
||||
}));
|
||||
|
||||
usort($files, static function (string $left, string $right): int {
|
||||
return strnatcasecmp(installationMigrationSortKey($left), installationMigrationSortKey($right));
|
||||
});
|
||||
|
||||
10
migrate.php
10
migrate.php
@ -102,6 +102,9 @@ function getMigrationFiles(): array
|
||||
$sqlFiles = glob(__DIR__ . '/db/migrations/*.sql') ?: [];
|
||||
$phpFiles = glob(__DIR__ . '/db/migrations/*.php') ?: [];
|
||||
$files = array_merge($sqlFiles, $phpFiles);
|
||||
$files = array_values(array_filter($files, static function (string $filePath): bool {
|
||||
return !isLegacyNumberedMigrationFile($filePath);
|
||||
}));
|
||||
|
||||
usort($files, static function (string $left, string $right): int {
|
||||
return strnatcasecmp(migrationSortKey($left), migrationSortKey($right));
|
||||
@ -110,6 +113,13 @@ function getMigrationFiles(): array
|
||||
return $files;
|
||||
}
|
||||
|
||||
function isLegacyNumberedMigrationFile(string $filePath): bool
|
||||
{
|
||||
// Old packaged builds sometimes carried numeric migrations like 001_*.sql / 002_*.sql
|
||||
// from a legacy orders-based schema. This project now uses date-based migrations instead.
|
||||
return preg_match('/^\d{1,7}_/', basename($filePath)) === 1;
|
||||
}
|
||||
|
||||
function splitSqlStatements(string $sql): array
|
||||
{
|
||||
$sql = preg_replace('/^\xEF\xBB\xBF/', '', $sql) ?? $sql;
|
||||
|
||||
@ -97,6 +97,12 @@ function schemaSnapshotMigrationSortKey(string $filePath): string
|
||||
};
|
||||
}
|
||||
|
||||
function isLegacyNumberedSnapshotMigrationFile(string $filePath): bool
|
||||
{
|
||||
// Skip obsolete pre-date-based migrations from older packaged builds.
|
||||
return preg_match('/^\d{1,7}_/', basename($filePath)) === 1;
|
||||
}
|
||||
|
||||
function fetchInstallBaselineMigrationNames(): array
|
||||
{
|
||||
$files = array_merge(
|
||||
@ -104,6 +110,10 @@ function fetchInstallBaselineMigrationNames(): array
|
||||
glob(__DIR__ . '/db/migrations/*.php') ?: []
|
||||
);
|
||||
|
||||
$files = array_values(array_filter($files, static function (string $filePath): bool {
|
||||
return !isLegacyNumberedSnapshotMigrationFile($filePath);
|
||||
}));
|
||||
|
||||
usort($files, static function (string $left, string $right): int {
|
||||
return strnatcasecmp(schemaSnapshotMigrationSortKey($left), schemaSnapshotMigrationSortKey($right));
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user