mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 21:40:39 +03:00
d3384975da
refs #12100 For performance reasons we want to add foreign key and unique constraints to the members_stripe_* tables so we can utilised cascading deletes and joins across the tables when querying. In order to do this we must first ensure that: - There are no duplicate entries in the `subscription_id` or `customer_id` columns - There are no orphaned rows in the subscription or customers tables If the first is not true, the unique constraint will fail, and if the second is not true, the foreign key constraint will fail. As we are only adding the indexes to existing MySQL databases at this point, the cleanup migrations will also only be done for existing MySQL databases too. The migrations for removing orphaned rows splits the deletion into a `SELECT` followed by a `WHERE IN` to avoid the database "optimising" the query into a `JOIN` which ends up taking much longer due to the lack of indexes. |
||
---|---|---|
.. | ||
client@4915f6aee2 | ||
frontend | ||
server | ||
shared | ||
index.js |