forked from joshmarcus/philly_legislative
-
Notifications
You must be signed in to change notification settings - Fork 20
Useful scripts
mjumbewu edited this page Jul 18, 2012
·
1 revision
I had to get rid of a bunch of duplicate actions, so I ran the following queries:
-- Copy the distinct records into a new table, keeping the earliest created and -- updated times. select file_id, description, motion, acting_body, notes, minutes_id, date_taken, min(created_datetime) as created_datetime, min(updated_datetime) as updated_datetime into phillyleg_legaction2 from phillyleg_legaction group by file_id, description, motion, acting_body, notes, minutes_id, date_taken; -- Get rid of all the data from the original table. truncate table phillyleg_legaction; -- Copy the data from the new table back into the original. insert into phillyleg_legaction (file_id, description, motion, acting_body, notes, minutes_id, date_taken, created_datetime, updated_datetime) select * from phillyleg_legaction2; -- Finally, get rid of the new table. drop table phillyleg_legaction2;
Of course you should back up your database before doing this (as I did not). Credit goes to @atogle for giving me the obvious solution.