From afa3a34fbf6b6de2c147d669f8d9425a619b73d7 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 24 Aug 2014 02:10:00 +0200 Subject: [PATCH] Fixed initial setup. --- db/migrate/20120101000001_create_base.rb | 5 +++++ ...0001_update_recent_viewed_create_object_lookup.rb | 12 ++++++++---- ...823000002_update_activity_stream_object_lookup.rb | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/db/migrate/20120101000001_create_base.rb b/db/migrate/20120101000001_create_base.rb index a5411f1c0..2343ec5c2 100644 --- a/db/migrate/20120101000001_create_base.rb +++ b/db/migrate/20120101000001_create_base.rb @@ -144,6 +144,11 @@ class CreateBase < ActiveRecord::Migration add_index :translations, [:source] add_index :translations, [:locale] + create_table :object_lookups do |t| + t.column :name, :string, :limit => 250, :null => false + t.timestamps + end + add_index :object_lookups, [:name], :unique => true end end diff --git a/db/migrate/20140823000001_update_recent_viewed_create_object_lookup.rb b/db/migrate/20140823000001_update_recent_viewed_create_object_lookup.rb index eeffa6e88..8d3e043ad 100644 --- a/db/migrate/20140823000001_update_recent_viewed_create_object_lookup.rb +++ b/db/migrate/20140823000001_update_recent_viewed_create_object_lookup.rb @@ -1,11 +1,13 @@ class UpdateRecentViewedCreateObjectLookup < ActiveRecord::Migration def up - create_table :object_lookups do |t| - t.column :name, :string, :limit => 250, :null => false - t.timestamps + if !ActiveRecord::Base.connection.table_exists? 'object_lookups' + create_table :object_lookups do |t| + t.column :name, :string, :limit => 250, :null => false + t.timestamps + end + add_index :object_lookups, [:name], :unique => true end - add_index :object_lookups, [:name], :unique => true RecentView.all.each {|entry| ro = RecentView::Object.find(entry.recent_view_object_id) lookup_id = ObjectLookup.by_name( ro.name ) @@ -15,6 +17,8 @@ class UpdateRecentViewedCreateObjectLookup < ActiveRecord::Migration rename_column :recent_views, :recent_view_object_id, :object_lookup_id drop_table :recent_view_objects + + Cache.clear end def down diff --git a/db/migrate/20140823000002_update_activity_stream_object_lookup.rb b/db/migrate/20140823000002_update_activity_stream_object_lookup.rb index 069a8cfce..7dae9a53b 100644 --- a/db/migrate/20140823000002_update_activity_stream_object_lookup.rb +++ b/db/migrate/20140823000002_update_activity_stream_object_lookup.rb @@ -7,8 +7,8 @@ class UpdateActivityStreamObjectLookup < ActiveRecord::Migration entry.update_attribute( :activity_stream_object_id, lookup_id ) entry.cache_delete } - drop_table :activity_stream_objects + Cache.clear end def down