Fixed initial setup.

This commit is contained in:
Martin Edenhofer 2014-08-24 02:10:00 +02:00
parent fe2b760612
commit afa3a34fbf
3 changed files with 14 additions and 5 deletions

View file

@ -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

View file

@ -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

View file

@ -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