Skip to content

Commit

Permalink
detach all likes on non-comment posts.
Browse files Browse the repository at this point in the history
  • Loading branch information
zxy19 committed Oct 17, 2024
1 parent 2081ab7 commit 90641ae
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/

use Illuminate\Database\Schema\Builder;

return [
'up' => function (Builder $schema) {
// Detach likes on non-comment posts
$schema->getConnection()
->table('post_likes')
->whereNotExists(function ($query) {
$query->selectRaw(1)->from('posts')->whereColumn('id', 'post_id')->where('type', 'comment');
})
->delete();
},
'down' => function (Builder $schema) {
}
];

0 comments on commit 90641ae

Please sign in to comment.