aboutsummaryrefslogtreecommitdiffstats
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/migrate/052_include_event_foreign_references.rb25
-rw-r--r--db/schema.rb12
2 files changed, 32 insertions, 5 deletions
diff --git a/db/migrate/052_include_event_foreign_references.rb b/db/migrate/052_include_event_foreign_references.rb
new file mode 100644
index 000000000..faa853ef4
--- /dev/null
+++ b/db/migrate/052_include_event_foreign_references.rb
@@ -0,0 +1,25 @@
+class IncludeEventForeignReferences < ActiveRecord::Migration
+ def self.up
+ add_column :info_request_events, :incoming_message_id, :integer
+ add_column :info_request_events, :outgoing_message_id, :integer
+ for event in InfoRequestEvent.find(:all)
+ #STDERR.puts "event " + event.id.to_s
+ incoming_message = event.incoming_message_via_params
+ if not incoming_message.nil?
+ event.incoming_message_id = incoming_message.id
+ end
+ outgoing_message = event.outgoing_message_via_params
+ if not outgoing_message.nil?
+ event.outgoing_message_id = outgoing_message.id
+ end
+ event.save!
+ end
+ execute "ALTER TABLE info_request_events ADD CONSTRAINT fk_info_request_events_incoming_message_id FOREIGN KEY (incoming_message_id) REFERENCES incoming_messages(id)"
+ execute "ALTER TABLE info_request_events ADD CONSTRAINT fk_info_request_events_outgoing_message_id FOREIGN KEY (outgoing_message_id) REFERENCES outgoing_messages(id)"
+ end
+
+ def self.down
+ remove_column :info_request_events, :outgoing_message_id
+ remove_column :info_request_events, :incoming_message_id
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 5e1982b16..331f7adbe 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 51) do
+ActiveRecord::Schema.define(:version => 52) do
create_table "incoming_messages", :force => true do |t|
t.integer "info_request_id", :null => false
@@ -19,13 +19,15 @@ ActiveRecord::Schema.define(:version => 51) do
end
create_table "info_request_events", :force => true do |t|
- t.integer "info_request_id", :null => false
- t.text "event_type", :null => false
- t.text "params_yaml", :null => false
- t.datetime "created_at", :null => false
+ t.integer "info_request_id", :null => false
+ t.text "event_type", :null => false
+ t.text "params_yaml", :null => false
+ t.datetime "created_at", :null => false
t.string "described_state"
t.string "calculated_state"
t.datetime "last_described_at"
+ t.integer "incoming_message_id"
+ t.integer "outgoing_message_id"
end
create_table "info_requests", :force => true do |t|