From 61e3bad83f767be05a782d191b352a7a2a643764 Mon Sep 17 00:00:00 2001 From: Adam Cooke Date: Mon, 8 May 2017 16:39:13 +0100 Subject: [PATCH] add method for cleaning the message database --- lib/postal/message_db/provisioner.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/postal/message_db/provisioner.rb b/lib/postal/message_db/provisioner.rb index a13208b..5abf79f 100644 --- a/lib/postal/message_db/provisioner.rb +++ b/lib/postal/message_db/provisioner.rb @@ -63,6 +63,18 @@ module Postal @database.query("DROP TABLE `#{@database.database_name}`.`#{table_name}`") end + # + # Clean the database. This really only useful in development & testing + # environment and can be quite dangerous in production. + # + def clean + ['clicks', 'deliveries', 'links', 'live_stats', 'loads', 'messages', + 'raw_message_sizes', 'spam_checks', 'stats_daily', 'stats_hourly', + 'stats_monthly', 'stats_yearly', 'suppressions', 'webhook_requests'].each do |table| + @database.query("TRUNCATE `#{@database.database_name}`.`#{table}`") + end + end + # # Creates a new empty raw message table for the given date. Returns nothing. #