1
0
Fork 0
mirror of https://github.com/archtechx/laravel-tips.git synced 2025-12-12 21:34:03 +00:00
laravel-tips/content/tips/partial-indexes-are-useful-for-enforcing-rules-that-only-apply-conditionally.md
Samuel Štancl 99fc7428d1 Week 20/2022
2022-05-22 13:50:08 +02:00

656 B
Raw Blame History

title tweet_id thread_slug author_username images created_at slug
Partial indexes are useful for enforcing rules that only apply conditionally 1527688613932044289 weekly-thread-2022-20 tobias_petry
https://pbs.twimg.com/media/FTCG2anXoAIB0U2.jpg
2022-05-20T16:32:03+00:00 partial-indexes-are-useful-for-enforcing-rules-that-only-apply-conditionally

Database Tip

Sometimes you want to make columns unique but you can't because e.g. there are still soft-deleted rows in the table witht the same value. By only including relevant rows (partial index) you can still enforce uniqueness, and you can even simulate it for MySQL!