Skip to content

Commit

Permalink
Add script to migrate events from archive to the weekend table. Also …
Browse files Browse the repository at this point in the history
…add job_id to the events view.
  • Loading branch information
GraylinKim committed Aug 14, 2012
1 parent 6062b0e commit b206624
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
35 changes: 35 additions & 0 deletions resources/archive2weekend.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
SET @start_date := '2012-08-10 01:37:00';
SET @end_date := '2012-08-13 12:33:00';

DROP VIEW IF EXISTS events;
CREATE VIEW events AS
SELECT a.event_id as id,
a.email,
m.category,
a.event_type,
m.mailing_id,
a.job_id,
a.queue_id,
i.name as instance,
i.install_class,
i.servername,
a.result,
a.dt_created,
a.dt_received,
a.dt_processed,
a.is_test
FROM archive a
JOIN message m ON a.message_id=m.id
JOIN instance i ON m.instance_id=i.id;

BEGIN;

INSERT INTO weekend_events
(email, category, event_type, mailing_id, job_id, queue_id, instance, install_class, servername, dt_created, dt_received, is_test)
SELECT
email, category, event_type, mailing_id, job_id, queue_id, instance, install_class, servername, dt_created, dt_received, is_test
FROM events WHERE dt_processed > @start_date AND dt_processed < @end_date;

DELETE FROM archive WHERE dt_processed > @start_date AND dt_processed < @end_date;

COMMIT;
1 change: 1 addition & 0 deletions resources/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ SELECT a.event_id as id,
m.category,
a.event_type,
m.mailing_id,
m.job_id,
a.queue_id,
i.name as instance,
i.install_class,
Expand Down

0 comments on commit b206624

Please sign in to comment.