Skip to content

Instantly share code, notes, and snippets.

@mage2k
Created December 16, 2008 19:27
Show Gist options
  • Select an option

  • Save mage2k/36737 to your computer and use it in GitHub Desktop.

Select an option

Save mage2k/36737 to your computer and use it in GitHub Desktop.
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