diff options
Diffstat (limited to 'db')
5 files changed, 51 insertions, 0 deletions
diff --git a/db/migrate/20130731142632_remove_prominence_from_info_request_event.rb b/db/migrate/20130731142632_remove_prominence_from_info_request_event.rb new file mode 100644 index 000000000..df0278c20 --- /dev/null +++ b/db/migrate/20130731142632_remove_prominence_from_info_request_event.rb @@ -0,0 +1,9 @@ +class RemoveProminenceFromInfoRequestEvent < ActiveRecord::Migration + def up + remove_column :info_request_events, :prominence + end + + def down + add_column :info_request_events, :prominence, :string, :null => false, :default => 'normal' + end +end diff --git a/db/migrate/20130731145325_add_prominence_to_incoming_message.rb b/db/migrate/20130731145325_add_prominence_to_incoming_message.rb new file mode 100644 index 000000000..01c4906a7 --- /dev/null +++ b/db/migrate/20130731145325_add_prominence_to_incoming_message.rb @@ -0,0 +1,5 @@ +class AddProminenceToIncomingMessage < ActiveRecord::Migration + def change + add_column :incoming_messages, :prominence, :string, :null => false, :default => 'normal' + end +end diff --git a/db/migrate/20130801154033_add_prominence_reason_to_incoming_message.rb b/db/migrate/20130801154033_add_prominence_reason_to_incoming_message.rb new file mode 100644 index 000000000..2d189f658 --- /dev/null +++ b/db/migrate/20130801154033_add_prominence_reason_to_incoming_message.rb @@ -0,0 +1,5 @@ +class AddProminenceReasonToIncomingMessage < ActiveRecord::Migration + def change + add_column :incoming_messages, :prominence_reason, :text + end +end diff --git a/db/migrate/20130816150110_add_statistics_to_public_body.rb b/db/migrate/20130816150110_add_statistics_to_public_body.rb new file mode 100644 index 000000000..fb3a67e83 --- /dev/null +++ b/db/migrate/20130816150110_add_statistics_to_public_body.rb @@ -0,0 +1,26 @@ +class AddStatisticsToPublicBody < ActiveRecord::Migration + def self.up + add_column :public_bodies, :info_requests_successful_count, :integer + add_column :public_bodies, :info_requests_not_held_count, :integer + add_column :public_bodies, :info_requests_overdue_count, :integer + # We need to set the :info_requests_successful_count and + # :info_requests_not_held_count columns, since they will + # subsequently will be updated in after_save / + # after_destroy. :info_requests_overdue_count, however will be set + # from a periodically run rake task. + PublicBody.connection.execute("UPDATE public_bodies + SET info_requests_not_held_count = (SELECT COUNT(*) FROM info_requests + WHERE described_state = 'not_held' AND + public_body_id = public_bodies.id);") + PublicBody.connection.execute("UPDATE public_bodies + SET info_requests_successful_count = (SELECT COUNT(*) FROM info_requests + WHERE described_state IN ('successful', 'partially_successful') AND + public_body_id = public_bodies.id);") + end + + def self.down + remove_column :public_bodies, :info_requests_successful_count + remove_column :public_bodies, :info_requests_not_held_count + remove_column :public_bodies, :info_requests_overdue_count + end +end diff --git a/db/migrate/20130822161803_add_prominence_fields_to_outgoing_message.rb b/db/migrate/20130822161803_add_prominence_fields_to_outgoing_message.rb new file mode 100644 index 000000000..a75e0d426 --- /dev/null +++ b/db/migrate/20130822161803_add_prominence_fields_to_outgoing_message.rb @@ -0,0 +1,6 @@ +class AddProminenceFieldsToOutgoingMessage < ActiveRecord::Migration + def change + add_column :outgoing_messages, :prominence, :string, :null => false, :default => 'normal' + add_column :outgoing_messages, :prominence_reason, :text + end +end |