aboutsummaryrefslogtreecommitdiffstats
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/migrate/022_create_info_request_events.rb24
-rw-r--r--db/schema.rb9
2 files changed, 32 insertions, 1 deletions
diff --git a/db/migrate/022_create_info_request_events.rb b/db/migrate/022_create_info_request_events.rb
new file mode 100644
index 000000000..fe7450773
--- /dev/null
+++ b/db/migrate/022_create_info_request_events.rb
@@ -0,0 +1,24 @@
+class CreateInfoRequestEvents < ActiveRecord::Migration
+ def self.up
+ create_table :info_request_events do |t|
+ t.column "info_request_id", :integer
+ t.column :event_type, :text
+ t.column :params_yaml, :text
+ t.column :created_at, :datetime
+ end
+
+ # Create the missing events for requests already sent
+ InfoRequest.find(:all).each do |info_request|
+ info_request_event = InfoRequestEvent.new
+ info_request_event.event_type = 'sent'
+ info_request_event.params = { :email => info_request.recipient_email, :outgoing_message_id => info_request.outgoing_messages[0].id }
+ info_request_event.info_request = info_request
+ info_request_event.created_at = info_request.outgoing_messages[0].sent_at
+ info_request_event.save!
+ end
+ end
+
+ def self.down
+ drop_table :info_request_events
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index b8fbac966..f2032fdc5 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -2,7 +2,7 @@
# migrations feature of ActiveRecord to incrementally modify your database, and
# then regenerate this schema definition.
-ActiveRecord::Schema.define(:version => 21) do
+ActiveRecord::Schema.define(:version => 22) do
create_table "incoming_messages", :force => true do |t|
t.column "info_request_id", :integer
@@ -13,6 +13,13 @@ ActiveRecord::Schema.define(:version => 21) do
t.column "contains_information", :boolean
end
+ create_table "info_request_events", :force => true do |t|
+ t.column "info_request_id", :integer
+ t.column "event_type", :text
+ t.column "params_yaml", :text
+ t.column "created_at", :datetime
+ end
+
create_table "info_requests", :force => true do |t|
t.column "title", :text
t.column "user_id", :integer