-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update: drop user_id for owner morphs
- Loading branch information
Showing
5 changed files
with
43 additions
and
14 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
database/migrations/2024_11_12_000006_drop_user_id_for_owner.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
public function up(): void | ||
{ | ||
Schema::table('audit_changes', function (Blueprint $table) { | ||
$table->morphs('owner'); | ||
$table->dropColumn('user_id'); | ||
}); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
Schema::table('audit_changes', function (Blueprint $table) { | ||
$table | ||
->foreign('user_id') | ||
->references(config('activity-logger.user.foreign_key', 'id')) | ||
->on(config('activity-logger.user.table', 'users')) | ||
->onDelete('RESTRICT'); | ||
$table->dropColumn('owner_id'); | ||
$table->dropColumn('owner_type'); | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters