Skip to content

Commit

Permalink
update: make owner_id and owner_type nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
rbondoc96 committed Nov 14, 2024
1 parent a9c79d0 commit 745054f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion database/migrations/2024_11_12_000006_drop_user_id_for_owner.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,32 @@
public function up(): void
{
Schema::table('audit_changes', function (Blueprint $table) {
$table->morphs('owner');
$table->mediumInteger('owner_type', false, true)->nullable();
$table->integer('owner_id', false, true)->nullable();

$table->dropColumn('user_id');
});
}

public function down(): void
{
Schema::table('audit_changes', function (Blueprint $table) {
$table->addColumn(
config('activity-logger.user.foreign_key_type', 'bigInteger'),
'user_id',
[
'autoIncrement' => false,
'unsigned' => true,
]
)
->nullable();

$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');
});
Expand Down

0 comments on commit 745054f

Please sign in to comment.