Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: spatie/laravel-package-tools
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.19.0
Choose a base ref
...
head repository: spatie/laravel-package-tools
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1.20.0
Choose a head ref
  • 8 commits
  • 5 files changed
  • 3 contributors

Commits on Feb 6, 2025

  1. Update CHANGELOG

    freekmurze authored and github-actions[bot] committed Feb 6, 2025
    Copy the full SHA
    98db123 View commit details

Commits on Mar 14, 2025

  1. Fix: Migration Name Prefixed with by timestamp twice

    tech-wolf-tw committed Mar 14, 2025
    Copy the full SHA
    d1c25d6 View commit details

Commits on Mar 16, 2025

  1. Fix: Uncommited File added

    tech-wolf-tw committed Mar 16, 2025
    Copy the full SHA
    2303784 View commit details

Commits on Mar 21, 2025

  1. Removed Constant and made as inline

    tech-wolf-tw committed Mar 21, 2025
    Copy the full SHA
    f31cae3 View commit details
  2. Testcase Fixes Resolved

    tech-wolf-tw committed Mar 21, 2025
    Copy the full SHA
    8f19a0f View commit details
  3. Testcase Fixes Resolved

    tech-wolf-tw committed Mar 21, 2025
    Copy the full SHA
    fdca3c7 View commit details
  4. Merge pull request #162 from tech-wolf-tw/fix/issue-153-strip-timesta…

    …mp-prefix-migration
    
    Fix: Migration Name Prefixed with by timestamp twice
    freekmurze authored Mar 21, 2025
    Copy the full SHA
    b0b509b View commit details
  5. Update CHANGELOG

    freekmurze authored and github-actions[bot] committed Mar 21, 2025
    3
    Copy the full SHA
    0e4c5e3 View commit details
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,27 @@

All notable changes to `laravel-package-tools` will be documented in this file.

## 1.91.1 - 2025-03-21

### What's Changed

* Fix: Migration Name Prefixed with by timestamp twice by @tech-wolf-tw in https://github.com/spatie/laravel-package-tools/pull/162

### New Contributors

* @tech-wolf-tw made their first contribution in https://github.com/spatie/laravel-package-tools/pull/162

**Full Changelog**: https://github.com/spatie/laravel-package-tools/compare/1.19.0...1.91.1

## 1.19.0 - 2025-02-06

### What's Changed

* Laravel 12 Support by @erikn69 in https://github.com/spatie/laravel-package-tools/pull/160
* Ignore .phpunit.cache by @erikn69 in https://github.com/spatie/laravel-package-tools/pull/161

**Full Changelog**: https://github.com/spatie/laravel-package-tools/compare/1.18.3...1.19.0

## 1.18.3 - 2025-01-22

- avoid method name collisions
10 changes: 8 additions & 2 deletions src/PackageServiceProvider.php
Original file line number Diff line number Diff line change
@@ -373,9 +373,15 @@ protected function generateMigrationName(string $migrationFileName, Carbon $now)
}
}

$migrationFileName = self::stripTimestampPrefix($migrationFileName);
$timestamp = $now->format('Y_m_d_His');
$migrationFileName = Str::of($migrationFileName)->snake()->finish('.php');
$formattedFileName = Str::of($migrationFileName)->snake()->finish('.php');

return database_path($migrationsPath . $timestamp . '_' . $migrationFileName);
return database_path("{$migrationsPath}{$timestamp}_{$formattedFileName}");
}

private static function stripTimestampPrefix(string $filename): string
{
return preg_replace('/^\d{4}_\d{2}_\d{2}_\d{6}_/', '', $filename);
}
}
Original file line number Diff line number Diff line change
@@ -60,6 +60,6 @@ public function configurePackage(Package $package)
/** @var \Illuminate\Database\Migrations\Migrator $migrator */
$migrator = app('migrator');

$this->assertCount(5, $migrator->paths());
$this->assertStringContainsString('laravel_package_tools', $migrator->paths()[0]);
$this->assertCount(6, $migrator->paths());
$this->assertStringContainsString('laravel_package_tools', $migrator->paths()[1]);
});
12 changes: 11 additions & 1 deletion tests/PackageServiceProviderTests/PackageMigrationTest.php
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ public function configurePackage(Package $package)
->name('laravel-package-tools')
->hasMigration('create_another_laravel_package_tools_table')
->hasMigration('create_regular_laravel_package_tools_table')
->hasMigration('2025_03_14_011123_create_custom_table')
->runsMigrations();
}
}
@@ -28,6 +29,15 @@ public function configurePackage(Package $package)
assertMigrationPublished('create_another_laravel_package_tools_table.php');
});

it('can publish migration with a prefixed timestamp', function () {
$this
->artisan('vendor:publish --tag=package-tools-migrations')
->doesntExpectOutput('hey')
->assertExitCode(0);

assertMigrationPublished('2020_01_01_000003_create_custom_table.php');
});

it('can publish the migration without being stubbed', function () {
$this
->artisan('vendor:publish --tag=package-tools-migrations')
@@ -80,6 +90,6 @@ public function configurePackage(Package $package)
/** @var \Illuminate\Database\Migrations\Migrator $migrator */
$migrator = app('migrator');

$this->assertCount(2, $migrator->paths());
$this->assertCount(3, $migrator->paths());
$this->assertStringContainsString('laravel_package_tools', $migrator->paths()[0]);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateCustomTable extends Migration
{
public function up()
{
Schema::create('custom', function (Blueprint $table) {
$table->bigIncrements('id');

$table->timestamps();
});
}
}