Skip to content

Commit d114762

Browse files
Added notifications when upgrade command running
1 parent e60259a commit d114762

File tree

2 files changed

+63
-9
lines changed

2 files changed

+63
-9
lines changed

docs/prologue/upgrade.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,47 @@
11
# Upgrade Guide
22

3+
## High Impact Changes
4+
5+
- Replacing named classes with anonymous ones
6+
- Change the location of the configuration file
7+
- Changing the namespace of the parent class
8+
- Changing variable names from `snake_case` to `camelCase`
9+
- Added recursive search for actions in a folder
10+
- PHP 7.3 and 7.4 was dropped
11+
- Laravel 6.0 was dropped
12+
- Dragon Code: Contracts (`dragon-code/contracts`) was dropped
13+
14+
## Medium Impact Changes
15+
16+
- Changing the name of an action column in the database
17+
- Action storage directory changed
18+
319
## Upgrading To 3.x from 2.x
20+
21+
### Updating Dependencies
22+
23+
#### PHP 8.0.2 Required
24+
25+
Laravel Actions now requires PHP 8.0.2 or greater.
26+
27+
#### Composer Dependencies
28+
29+
You should update the following dependency in your application's `composer.json` file:
30+
31+
- `dragon-code/laravel-migration-actions` to `^3.0`
32+
33+
### Call Upgrade Command
34+
35+
For your convenience, we have created an upgrade console command:
36+
37+
```bash
38+
php artisan migrate:actions:upgrade
39+
```
40+
41+
It will do the following:
42+
43+
- Change the namespace of the abstract class
44+
- Add a strict type declaration
45+
- Replace the `up` method with `__invoke` if the class does not have a `down` method
46+
- Replace named classes with anonymous ones
47+
- Create a configuration file according to the data saved in your project

src/Processors/Upgrade.php

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ protected function run(): void
2727
{
2828
$this->moveFiles();
2929
$this->moveConfig();
30+
$this->clean();
3031
}
3132

3233
protected function moveFiles(): void
@@ -49,6 +50,13 @@ protected function move(string $filename): void
4950
$this->delete($filename);
5051
}
5152

53+
protected function clean(): void
54+
{
55+
$this->notification->task('Delete old directory', fn () => Directory::ensureDelete(
56+
database_path('actions')
57+
));
58+
}
59+
5260
protected function open(string $path): string
5361
{
5462
return file_get_contents(base_path('database/actions/' . $path));
@@ -100,23 +108,25 @@ protected function replaceWithInvoke(string $content): string
100108

101109
protected function moveConfig(): void
102110
{
103-
$this->artisan('vendor:publish', [
104-
'--provider' => ServiceProvider::class,
105-
'--force' => true,
106-
]);
111+
$this->notification->task('Moving config file', function () {
112+
$this->artisan('vendor:publish', [
113+
'--provider' => ServiceProvider::class,
114+
'--force' => true,
115+
]);
107116

108-
$path = config_path('actions.php');
117+
$path = config_path('actions.php');
109118

110-
$table = config('database.actions', 'migration_actions');
119+
$table = config('database.actions', 'migration_actions');
111120

112-
$content = Str::replace(file_get_contents($path), "'table' => 'migration_actions'", "'table' => '$table'");
121+
$content = Str::replace(file_get_contents($path), "'table' => 'migration_actions'", "'table' => '$table'");
113122

114-
file_put_contents($path, $content);
123+
file_put_contents($path, $content);
124+
});
115125
}
116126

117127
protected function getOldFiles(): array
118128
{
119-
return $this->getFiles(path: base_path('database/actions'));
129+
return $this->getFiles(path: database_path('actions'));
120130
}
121131

122132
protected function alreadyUpgraded(): bool

0 commit comments

Comments
 (0)