Skip to content

Commit 82a8c39

Browse files
committed
Merge branch 'main' of github.com:laracraft-tech/laravel-useful-additions into main
2 parents 3d11127 + 3d1d5ca commit 82a8c39

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All notable changes to `laravel-useful-additions` will be documented in this file.
44

5+
## v3.2.0 - 2023-03-12
6+
7+
Added options for `db:truncate` command.
8+
59
## v3.1.0 - 2023-03-12
610

711
Added `db:truncate` command

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,19 +168,22 @@ class MyTest extends TestCase
168168

169169
---
170170

171-
This command truncates all the tables of your current database connection:
171+
This command truncates all the tables of your current database connection. Checkout `--help` to see arguments and options.
172+
It for instance, lets you also truncate only **specific** tables or disable **foreigen key checks** or maybe run in **force** mode.
172173

173174
```bash
174175
php artisan db:truncate
175176
```
176177
```
177-
INFO Preparing database.
178+
INFO Start truncating tables.
178179
179180
Truncating table: failed_jobs .............................................. 135ms DONE
180181
Truncating table: migrations ................................................ 87ms DONE
181182
Truncating table: password_reset_tokens ..................................... 79ms DONE
182183
Truncating table: personal_access_tokens .................................... 86ms DONE
183184
Truncating table: users ..................................................... 78ms DONE
185+
186+
INFO Finished truncating tables.
184187
```
185188

186189
## Testing

src/Commands/DBTruncateCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function handle(): int
2525

2626
$foreignKeyChecks = $this->hasOption('checks') && filter_var($this->option('checks'), FILTER_VALIDATE_BOOLEAN);
2727

28-
if (!$foreignKeyChecks) {
28+
if (! $foreignKeyChecks) {
2929
$this->components->warn('Disabling foreign key checks!');
3030
Schema::disableForeignKeyConstraints();
3131
}
@@ -46,7 +46,7 @@ public function handle(): int
4646

4747
$this->components->info('Finished truncating tables.');
4848

49-
if (!$foreignKeyChecks) {
49+
if (! $foreignKeyChecks) {
5050
$this->components->warn('Re-enabling foreign key checks!');
5151
Schema::enableForeignKeyConstraints();
5252
}

0 commit comments

Comments
 (0)