Created
December 16, 2008 19:27
-
-
Save mage2k/36737 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| begin; | |
| select count(*) | |
| from actions | |
| where item_type='Story' | |
| and item_published_at is not null; | |
| select count(distinct(item_id)) | |
| from actions | |
| where item_type='Story' | |
| and item_published_at is not null; | |
| update actions a | |
| set item_published_at = s.published_at | |
| from (select s2.id, s2.published_at | |
| from stories s2, actions a2 | |
| where a2.item_published_at is null and a2.item_type='Story' | |
| and a2.item_id=s2.id | |
| limit 100) s | |
| WHERE a.item_id = s.id; | |
| update actions a | |
| set item_published_at = s.published_at | |
| from (select s2.id, s2.published_at | |
| from stories s2, actions a2 | |
| where a2.item_published_at is null and a2.item_type='Story' | |
| and a2.item_id=s2.id | |
| limit 100) s | |
| WHERE a.item_id = s.id; | |
| select count(*) | |
| from actions | |
| where item_type='Story' | |
| and item_published_at is not null; | |
| select count(distinct(item_id)) | |
| from actions | |
| where item_type='Story' | |
| and item_published_at is not null; | |
| rollback; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment