dev-resources.site
for different kinds of informations.
Laravel upgrade 10 to 11 Modifying Columns change
Published at
8/28/2024
Categories
laravel
Author
Luigui Moreno
Categories
1 categories in total
laravel
open
Acá un script para cuando se actualize Laravel de la version 10 a la 11, este script permite encontrar los archivos a donde esta la columna de una tabla a la que se le han hecho cambios
Here's a script for when Laravel is updated from version 10 to 11. This script allows you to find the files where the column of a table that has undergone changes is located.
<?php
function searchMigrations($directory, $tableName, $columnName) {
$pattern = '/(?:create|table)\s*\(\s*[\'"]' . preg_quote($tableName, '/') . '[\'"].*?\$table.*?[\'"]' . preg_quote($columnName, '/') . '[\'"\)]/is';
$migrations = glob($directory . '/*_*.php');
$matches = [];
foreach ($migrations as $migration) {
$content = file_get_contents($migration);
if (preg_match($pattern, $content)) {
$matches[] = $migration;
}
}
return $matches;
}
// Verificar si se proporcionaron los argumentos necesarios
if ($argc < 3) {
echo "Uso: php " . $argv[0] . " <nombre_tabla> <nombre_columna>\n";
echo "Ejemplo: php " . $argv[0] . " pedidos user_id\n";
exit(1);
}
$migrationsDir = __DIR__ . '/database/migrations';
$tableName = $argv[1];
$columnName = $argv[2];
echo "Buscando migraciones para la tabla '$tableName' y la columna '$columnName'...\n\n";
$results = searchMigrations($migrationsDir, $tableName, $columnName);
if (empty($results)) {
echo "No se encontraron migraciones que coincidan con los criterios.\n";
} else {
foreach ($results as $file) {
echo realpath($file) . "\n";
}
echo "\nTotal de migraciones encontradas: " . count($results) . "\n";
}
Articles
9 articles in total
Laravel upgrade 10 to 11 Modifying Columns change
currently reading
Macbook air m1 vs macbook pro 15 2018 vs mac mini 2018
read article
Scroll to the end of x bookmarks
read article
Phpstorm Intellij search mode when focusing
read article
Laravel Websockets in valet cURL error 60: SSL certificate problem: unable to get local issuer certificate
read article
Migrate Laravel factories to class factories
read article
Clean your git branches local and remote
read article
Laravel model factories with relation sharing foreign keys
read article
Post de bienvenida
read article
Featured ones: