Merged several migrations.

This commit is contained in:
Martin Edenhofer 2014-12-17 16:40:59 +01:00
parent 2e8b0469f0
commit 6e37f4a2a6
8 changed files with 64 additions and 169 deletions

View file

@ -16,6 +16,7 @@ class CreateBase < ActiveRecord::Migration
t.column :lastname, :string, :limit => 100, :null => true
t.column :email, :string, :limit => 140, :null => true
t.column :image, :string, :limit => 100, :null => true
t.column :image_source, :string, :limit => 200, :null => true
t.column :web, :string, :limit => 100, :null => true
t.column :password, :string, :limit => 100, :null => true
t.column :phone, :string, :limit => 100, :null => true
@ -41,6 +42,7 @@ class CreateBase < ActiveRecord::Migration
add_index :users, [:login], :unique => true
add_index :users, [:email]
# add_index :users, [:email], :unique => true
add_index :users, [:image]
add_index :users, [:department]
add_index :users, [:phone]
add_index :users, [:fax]
@ -192,6 +194,22 @@ class CreateBase < ActiveRecord::Migration
t.timestamps
end
create_table :taskbars do |t|
t.column :user_id, :integer, :null => false
t.column :last_contact, :datetime, :null => false
t.column :client_id, :string, :null => false
t.column :key, :string, :limit => 100, :null => false
t.column :callback, :string, :limit => 100, :null => false
t.column :state, :string, :limit => 8000, :null => true
t.column :params, :string, :limit => 2000, :null => true
t.column :prio, :integer, :null => false
t.column :notify, :boolean, :null => false, :default => false
t.column :active, :boolean, :null => false, :default => false
t.timestamps
end
add_index :taskbars, [:user_id]
add_index :taskbars, [:client_id]
create_table :tags do |t|
t.references :tag_item, :null => false
@ -215,6 +233,50 @@ class CreateBase < ActiveRecord::Migration
end
add_index :tag_items, [:name], :unique => true
end
end
create_table :object_lookups do |t|
t.column :name, :string, :limit => 250, :null => false
t.timestamps
end
add_index :object_lookups, [:name], :unique => true
create_table :type_lookups do |t|
t.column :name, :string, :limit => 250, :null => false
t.timestamps
end
add_index :type_lookups, [:name], :unique => true
create_table :recent_views do |t|
t.references :recent_view_object, :null => false
t.column :o_id, :integer, :null => false
t.column :created_by_id, :integer, :null => false
t.timestamps
end
add_index :recent_views, [:o_id]
add_index :recent_views, [:created_by_id]
add_index :recent_views, [:created_at]
add_index :recent_views, [:recent_view_object_id]
create_table :activity_streams do |t|
t.references :activity_stream_type, :null => false
t.references :activity_stream_object, :null => false
t.references :role, :null => true
t.references :group, :null => true
t.column :o_id, :integer, :null => false
t.column :created_by_id, :integer, :null => false
t.timestamps
end
add_index :activity_streams, [:o_id]
add_index :activity_streams, [:created_by_id]
add_index :activity_streams, [:role_id]
add_index :activity_streams, [:group_id]
add_index :activity_streams, [:created_at]
add_index :activity_streams, [:activity_stream_object_id]
add_index :activity_streams, [:activity_stream_type_id]
end
end

View file

@ -1,26 +0,0 @@
class CreateRecentViewed < ActiveRecord::Migration
def up
create_table :recent_views do |t|
t.references :recent_view_object, :null => false
t.column :o_id, :integer, :null => false
t.column :created_by_id, :integer, :null => false
t.timestamps
end
add_index :recent_views, [:o_id]
add_index :recent_views, [:created_by_id]
add_index :recent_views, [:created_at]
add_index :recent_views, [:recent_view_object_id]
create_table :recent_view_objects do |t|
t.column :name, :string, :limit => 250, :null => false
t.column :note, :string, :limit => 250, :null => true
t.timestamps
end
add_index :recent_view_objects, [:name], :unique => true
end
def down
drop_table :recent_views
drop_table :recent_view_objects
end
end

View file

@ -1,23 +0,0 @@
class TaskbarCreate < ActiveRecord::Migration
def up
create_table :taskbars do |t|
t.column :user_id, :integer, :null => false
t.column :last_contact, :datetime, :null => false
t.column :client_id, :string, :null => false
t.column :key, :string, :limit => 100, :null => false
t.column :callback, :string, :limit => 100, :null => false
t.column :state, :string, :limit => 8000, :null => true
t.column :params, :string, :limit => 2000, :null => true
t.column :prio, :integer, :null => false
t.column :notify, :boolean, :null => false, :default => false
t.column :active, :boolean, :null => false, :default => false
t.timestamps
end
add_index :taskbars, [:user_id]
add_index :taskbars, [:client_id]
end
def down
drop_table :taskbars
end
end

View file

@ -1,40 +0,0 @@
class CreateActivityStream < ActiveRecord::Migration
def up
create_table :activity_streams do |t|
t.references :activity_stream_type, :null => false
t.references :activity_stream_object, :null => false
t.references :role, :null => true
t.references :group, :null => true
t.column :o_id, :integer, :null => false
t.column :created_by_id, :integer, :null => false
t.timestamps
end
add_index :activity_streams, [:o_id]
add_index :activity_streams, [:created_by_id]
add_index :activity_streams, [:role_id]
add_index :activity_streams, [:group_id]
add_index :activity_streams, [:created_at]
add_index :activity_streams, [:activity_stream_object_id]
add_index :activity_streams, [:activity_stream_type_id]
create_table :activity_stream_types do |t|
t.column :name, :string, :limit => 250, :null => false
t.timestamps
end
add_index :activity_stream_types, [:name], :unique => true
create_table :activity_stream_objects do |t|
t.column :name, :string, :limit => 250, :null => false
t.column :note, :string, :limit => 250, :null => true
t.timestamps
end
add_index :activity_stream_objects, [:name], :unique => true
end
def down
drop_table :activity_streams
drop_table :activity_stream_objects
drop_table :activity_stream_types
end
end

View file

@ -1,14 +0,0 @@
class ChangeUser2 < ActiveRecord::Migration
def up
add_column :users, :image_source, :string, :limit => 200, :null => true
add_index :users, [:image]
User.all.each {|user|
puts "Update user #{user.login}"
user.image_source = user.image
user.save
}
end
def down
end
end

View file

@ -1,24 +0,0 @@
class UpdateRecentViewedCreateObjectLookup < ActiveRecord::Migration
def up
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
RecentView.all.each {|entry|
ro = RecentView::Object.find(entry.recent_view_object_id)
lookup_id = ObjectLookup.by_name( ro.name )
entry.update_attribute( :recent_view_object_id, lookup_id )
entry.cache_delete
}
drop_table :recent_view_objects
Cache.clear
end
def down
end
end

View file

@ -1,16 +0,0 @@
class UpdateActivityStreamObjectLookup < ActiveRecord::Migration
def up
ActivityStream.all.each {|entry|
ao = ActivityStream::Object.find(entry.activity_stream_object_id)
lookup_id = ObjectLookup.by_name( ao.name )
entry.update_attribute( :activity_stream_object_id, lookup_id )
entry.cache_delete
}
drop_table :activity_stream_objects
Cache.clear
end
def down
end
end

View file

@ -1,24 +0,0 @@
class UpdateActivityStreamCreateTypeLookup < ActiveRecord::Migration
def up
if !ActiveRecord::Base.connection.table_exists? 'type_lookups'
create_table :type_lookups do |t|
t.column :name, :string, :limit => 250, :null => false
t.timestamps
end
add_index :type_lookups, [:name], :unique => true
end
ActivityStream.all.each {|entry|
ro = ActivityStream::Type.find(entry.activity_stream_type_id)
lookup_id = TypeLookup.by_name( ro.name )
entry.update_attribute( :activity_stream_type_id, lookup_id )
entry.cache_delete
}
drop_table :activity_stream_types
Cache.clear
end
def down
end
end