Skip to content

Commit 77f70c1

Browse files
committed
fix: Fix instalation and migrations automatic name
1 parent a98e8b3 commit 77f70c1

File tree

4 files changed

+78
-58
lines changed

4 files changed

+78
-58
lines changed

composer.json

Lines changed: 55 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
{
22
"name": "panchodp/laravel-fifo",
33
"description": "Simple FIFO inventory system",
4-
"keywords": ["php","fifo","laravel", "inventory", "management"],
4+
"keywords": [
5+
"php",
6+
"fifo",
7+
"laravel",
8+
"inventory",
9+
"management"
10+
],
511
"type": "library",
612
"license": "MIT",
713
"minimum-stability": "stable",
@@ -11,56 +17,59 @@
1117
"LaravelFifo\\": "src/"
1218
}
1319
},
14-
"autoload-dev": {
15-
"psr-4": {
16-
"LaravelFifo\\Test\\": "tests",
17-
"Database\\Factories\\": "tests/Database/Factories/"
18-
}
19-
},
20-
"extra": {
21-
"laravel": {
22-
"providers": [
23-
"LaravelFifo\\Providers\\LaravelFifoServiceProvider"
24-
]
25-
}
26-
},
20+
"autoload-dev": {
21+
"psr-4": {
22+
"LaravelFifo\\Test\\": "tests",
23+
"Database\\Factories\\": "tests/Database/Factories/"
24+
}
25+
},
26+
"extra": {
27+
"laravel": {
28+
"providers": [
29+
"LaravelFifo\\Providers\\LaravelFifoServiceProvider"
30+
]
31+
}
32+
},
2733
"authors": [
2834
{
2935
"name": "Francisco De Pablo",
3036
"email": "[email protected]"
3137
}
3238
],
33-
"require": {
34-
"php": "^8.4.0"
35-
},
36-
"require-dev": {
37-
"orchestra/testbench": "^10.6",
38-
"spatie/ray": "^1.42",
39-
"laravel/pint": "^1.24",
40-
"larastan/larastan": "^3.6.1",
41-
"pestphp/pest": "^4.0.3",
42-
"rector/rector": "^2.1"
43-
},
44-
"scripts": {
45-
"test": [
46-
"./vendor/bin/pest"
47-
],
48-
"pint": [
49-
"./vendor/bin/pint"
50-
],
51-
"analyse": [
52-
"./vendor/bin/phpstan analyse"
53-
],
54-
"dry": [
55-
"./vendor/bin/rector process --dry-run"
56-
],
57-
"test:all": [
58-
"@test","@pint","@analyse","@dry"
59-
]
60-
},
61-
"config": {
62-
"allow-plugins": {
63-
"pestphp/pest-plugin": true
39+
"require": {
40+
"php": "^8.4.0"
41+
},
42+
"require-dev": {
43+
"orchestra/testbench": "^10.6",
44+
"spatie/ray": "^1.42",
45+
"laravel/pint": "^1.24",
46+
"larastan/larastan": "^3.6.1",
47+
"pestphp/pest": "^4.0.3",
48+
"rector/rector": "^2.1"
49+
},
50+
"scripts": {
51+
"test": [
52+
"./vendor/bin/pest"
53+
],
54+
"pint": [
55+
"./vendor/bin/pint"
56+
],
57+
"analyse": [
58+
"./vendor/bin/phpstan analyse"
59+
],
60+
"dry": [
61+
"./vendor/bin/rector process --dry-run"
62+
],
63+
"test:all": [
64+
"@test",
65+
"@pint",
66+
"@analyse",
67+
"@dry"
68+
]
69+
},
70+
"config": {
71+
"allow-plugins": {
72+
"pestphp/pest-plugin": true
73+
}
6474
}
65-
}
6675
}

src/Console/InstallCommand.php

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,31 @@ private function publishMigrations(): void
3434
{
3535
$this->info('Publishing migrations...');
3636

37-
$packageMigrations = __DIR__.'/../../database/migrations';
38-
$appMigrations = database_path('migrations');
39-
4037
$filesystem = new Filesystem();
38+
$sourcePath = __DIR__.'/../../database/migrations/create_fifo_transactions_table.php';
39+
40+
// Generate dynamic timestamp
41+
$timestamp = date('Y_m_d_His');
42+
$migrationName = "{$timestamp}_create_fifo_transactions_table.php";
43+
$destinationPath = database_path("migrations/{$migrationName}");
4144

42-
if ($filesystem->exists($packageMigrations)) {
43-
$filesystem->copyDirectory($packageMigrations, $appMigrations);
44-
$this->info('✓ Migrations published');
45+
if (!$filesystem->exists($destinationPath)) {
46+
// Check if migration already exists with different timestamp
47+
$existingMigrations = glob(database_path('migrations/*_create_fifo_transactions_table.php'));
48+
49+
if (!empty($existingMigrations) && !$this->option('force')) {
50+
$this->warn('! FIFO migration already exists. Use --force to overwrite.');
51+
return;
52+
}
53+
54+
if ($filesystem->exists($sourcePath)) {
55+
$filesystem->copy($sourcePath, $destinationPath);
56+
$this->info("✓ Migration created: {$migrationName}");
57+
} else {
58+
$this->error('! Source migration file not found');
59+
}
60+
} else {
61+
$this->warn('! Migration already exists with this timestamp');
4562
}
4663
}
4764

src/Providers/LaravelFifoServiceProvider.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ final class LaravelFifoServiceProvider extends ServiceProvider
1010
{
1111
public function boot(): void
1212
{
13-
$this->loadMigrationsFrom(__DIR__.'/../../database/migrations');
14-
15-
$this->publishes([
16-
__DIR__.'/../../database/migrations/2025-09-01_create_fifo_transactions_table.php' => database_path('migrations/2025-09-01_create_fifo_transactions_table.php'),
17-
], 'laravel-fifo-migrations');
18-
1913
if ($this->app->runningInConsole()) {
2014
$this->commands([
2115
\LaravelFifo\Console\InstallCommand::class,

0 commit comments

Comments
 (0)