- All
weight
values arefloat
now. Round them to getinteger
values as it was before - Find all
isReactedTo
method usages and replace it withhasReactedTo
- Find all
isReactedToWithType
method usages and replace it withhasReactedTo
- Find all
isNotReactedTo
method usages and replace it withhasNotReactedTo
- Find all
isNotReactedToWithType
method usages and replace it withhasNotReactedTo
- Find all
isReactedByWithType
method usages and replace it withisReactedBy
- Find all
isNotReactedByWithType
method usages and replace it withisNotReactedBy
- The
ReactionType
methodgetWeight
was renamed togetMass
. If you're using your own implementation ofReactionType
, please update the method name - Find all
whereReactedByWithType
method usages and replace it withwhereReactedBy
- Find all
whereReactedBy
method usages and replace firstReacter
argument withReacterable
and secondReactionType
argument with its string name - Find all
joinReactionCounterOfType
method usages and replace firstReactionType
argument with its string name - Find all
joinReactionCounterOfType
method usages and update virtual attributes prefix. It was changed fromreactions_
toreaction_{$type}_
- Find all
joinReactionTotal
method usages and update virtual attributes prefix. It was changed fromreactions_total
toreaction_total_
Run only after all preparations are done.
Automated migration process requires doctrine/dbal
composer package to be installed.
VERY IMPORTANT: Create backup of your production database!
php artisan love:upgrade-v7-to-v8
You can skip upgrading for this version if you haven't used Love
facade and using packaged traits in Reacterable
& Reactant
models.
Release v7 has new facade approach described in (#54).
Global Cog\Laravel\Love\Facades\Love
facade was removed in favor to new facades:
Cog\Laravel\Love\Reacter\Facades\Reacter
Cog\Laravel\Love\Reactant\Facades\Reactant
If you are implemented Cog\Contracts\Love\Reactable\Models\Reactable
& Cog\Contracts\Love\Reacterable\Models\Reacterable
contracts by yourself without using packaged traits you need to implement 2 new methods:
Reactable
model should haveviaLoveReactant
methodReacterable
model should haveviaLoveReacter
method
Release v6 is a total package refactoring with a lot of breaking changes. Most of the upgrade requirements couldn't be done automatically because of completely different API.
- Replace all
Cog\Contracts\Love\Likeable\Models\Likeable
withCog\Contracts\Love\Reactable\Models\Reactable
- Replace all
Cog\Laravel\Love\Likeable\Models\Traits\Likeable
withCog\Laravel\Love\Reactable\Models\Traits\Reactable
- Replace all
Cog\Contracts\Love\Liker\Models\Liker
withCog\Contracts\Love\Reacterable\Models\Reacterable
- Replace all
Cog\Laravel\Love\Liker\Models\Traits\Liker
withCog\Laravel\Love\Reacterable\Models\Traits\Reacterable
- Add
$table->unsignedBigInteger('love_reacter_id');
column to each table which models can react on content. - Add
$table->unsignedBigInteger('love_reactant_id');
column to each table which models can be reacted.
- Find all
whereLikedBy
method and replace it withwhereReactedByWithType
- Find all
whereDislikedBy
method and replace it withwhereReactedByWithType
- Find all
like
method and replace it withreactTo
- Find all
dislike
method and replace it withreactTo
- Find all
unlike
method and replace it withunreactTo
- Find all
undislike
method and replace it withunreactTo
- Find all
orderByLikesCount
method and replace it withjoinReactionCounterOfType
and commonorderBy
- Find all
orderByDislikesCount
method and replace it withjoinReactionCounterOfType
and commonorderBy
Run only after all preparations are done.
VERY IMPORTANT: Create backup of your production database!
php artisan love:upgrade-v5-to-v6
- Find all
like
method and replace it withlikeBy
- Find all
dislike
method and replace it withdislikeBy
- Find all
unlike
method and replace it withunlikeBy
- Find all
undislike
method and replace it withundislikeBy
- Find all
likeToggle
method and replace it withtoggleLikeBy
- Find all
dislikeToggle
method and replace it withtoggleDislikeBy
- Find all
liked
method and replace it withisLikedBy
- Find all
disliked
method and replace it withisDislikedBy
Because there are many breaking changes an upgrade is not that easy. There are many edge cases this guide does not cover. We accept PRs to improve this guide.
- If you have used
Cog\Likeable\Console\LikeableRecountCommand
console command you should use new nameCog\Laravel\Love\Console\Commands\Recount
- Note that command signature was changed from
likeable:recount {model?} {type?}
tolove:recount {model?} {type?}
- Find all
Cog\Likeable\Events\ModelWasDisliked
and replace withCog\Laravel\Love\Likeable\Events\LikeableWasDisliked
- Find all
Cog\Likeable\Events\ModelWasLiked
and replace withCog\Laravel\Love\Likeable\Events\LikeableWasLiked
- Find all
Cog\Likeable\Events\ModelWasUndisliked
and replace withCog\Laravel\Love\Likeable\Events\LikeableWasUndisliked
- Find all
Cog\Likeable\Events\ModelWasUnliked
and replace withCog\Laravel\Love\Likeable\Events\LikeableWasUnliked
- In all listeners which intercepts Likeable's events described above, replace
$event->model
to$event->likeable
Exceptions namespace were moved to the contracts namespace, were renamed
and extends \RuntimeException
instead of \Exception
now.
- Find all
Cog\Likeable\Exceptions\LikeTypeInvalidException
and replace withCog\Contracts\Love\Like\Exceptions\InvalidLikeType
- Find all
Cog\Likeable\Exceptions\ModelInvalidException
and replace withCog\Contracts\Love\Likeable\Exceptions\InvalidLikeable
- Find all
Cog\Likeable\Exceptions\LikerNotDefinedException
and replace withCog\Contracts\Love\Liker\Exceptions\InvalidLiker
- Find all
Cog\Likeable\Contracts\Like
and replace withCog\Contracts\Love\Like\Models\Like
- Find all
Cog\Likeable\Contracts\Likeable
and replace withCog\Contracts\Love\Likeable\Models\Likeable
- Find all
Cog\Likeable\Traits\Likeable
and replace withCog\Laravel\Love\Likeable\Models\Traits\Likeable
If you have used Cog\Likeable\Observers\ModelObserver
observer you should use new name Cog\Laravel\Love\Likeable\Observers\LikeableObserver
.
- Find all
Cog\Likeable\Contracts\LikeableService
and replace withCog\Contracts\Love\Likeable\Services\LikeableService
To make all changes in MySQL you could run these commands one by one.
Don't forget to make full database backup before making an upgrade!
Rename like
table to love_likes
:
ALTER TABLE `like` RENAME TO `love_likes`;
Update name of migration file in migrations
table from 2016_09_02_153301_create_like_table
to 2016_09_02_153301_create_love_likes_table
:
UPDATE `migrations`
SET `migration` = '2016_09_02_153301_create_love_likes_table'
WHERE `migration` = '2016_09_02_153301_create_like_table'
LIMIT 1;
Rename like_counter
table to love_like_counters
:
ALTER TABLE `like_counter` RENAME TO `love_like_counters`;
Update name of migration file in migrations
table from 2016_09_02_163301_create_like_counter_table
to 2016_09_02_163301_create_like_counters_table
:
UPDATE `migrations`
SET `migration` = '2016_09_02_163301_create_love_like_counters_table'
WHERE `migration` = '2016_09_02_163301_create_like_counter_table'
LIMIT 1;
Add nullable updated_at
column to love_likes
table:
ALTER TABLE `love_likes`
ADD COLUMN `updated_at` TIMESTAMP NULL DEFAULT NULL AFTER `created_at`;
Sync updated_at
column of love_likes
table with created_at
column (optional):
UPDATE `love_likes`
SET `updated_at` = `created_at`
WHERE `updated_at` IS NULL
AND id > 0;
Add nullable created_at
& updated_at
columns to love_like_counters
table:
ALTER TABLE `love_like_counters`
ADD COLUMN `created_at` TIMESTAMP NULL DEFAULT NULL AFTER `count`,
ADD COLUMN `updated_at` TIMESTAMP NULL DEFAULT NULL AFTER `created_at`;
Since v4 service provider automatically loading migration files, so you could delete
database/migrations/2016_09_02_153301_create_like_table.php
and
database/migrations/2016_09_02_163301_create_like_counter_table.php
migration files.
If you need to have them locally you could republish them and re-apply your local changes to keep them up to date.