From 6e37f4a2a61ae551c7f9adb0a2307017b6dc5743 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 17 Dec 2014 16:40:59 +0100 Subject: [PATCH] Merged several migrations. --- db/migrate/20120101000001_create_base.rb | 66 ++++++++++++++++++- .../20130512000001_create_recent_viewed.rb | 26 -------- db/migrate/20130529124443_taskbar_create.rb | 23 ------- .../20130925000001_create_activity_stream.rb | 40 ----------- db/migrate/20131102000000_change_user2.rb | 14 ---- ...date_recent_viewed_create_object_lookup.rb | 24 ------- ...02_update_activity_stream_object_lookup.rb | 16 ----- ...date_activity_stream_create_type_lookup.rb | 24 ------- 8 files changed, 64 insertions(+), 169 deletions(-) delete mode 100644 db/migrate/20130512000001_create_recent_viewed.rb delete mode 100644 db/migrate/20130529124443_taskbar_create.rb delete mode 100644 db/migrate/20130925000001_create_activity_stream.rb delete mode 100644 db/migrate/20131102000000_change_user2.rb delete mode 100644 db/migrate/20140823000001_update_recent_viewed_create_object_lookup.rb delete mode 100644 db/migrate/20140823000002_update_activity_stream_object_lookup.rb delete mode 100644 db/migrate/20140824000001_update_activity_stream_create_type_lookup.rb diff --git a/db/migrate/20120101000001_create_base.rb b/db/migrate/20120101000001_create_base.rb index 2f38788e7..e5f302a8a 100644 --- a/db/migrate/20120101000001_create_base.rb +++ b/db/migrate/20120101000001_create_base.rb @@ -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 \ No newline at end of file diff --git a/db/migrate/20130512000001_create_recent_viewed.rb b/db/migrate/20130512000001_create_recent_viewed.rb deleted file mode 100644 index 6e467bc1b..000000000 --- a/db/migrate/20130512000001_create_recent_viewed.rb +++ /dev/null @@ -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 diff --git a/db/migrate/20130529124443_taskbar_create.rb b/db/migrate/20130529124443_taskbar_create.rb deleted file mode 100644 index a407497d0..000000000 --- a/db/migrate/20130529124443_taskbar_create.rb +++ /dev/null @@ -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 diff --git a/db/migrate/20130925000001_create_activity_stream.rb b/db/migrate/20130925000001_create_activity_stream.rb deleted file mode 100644 index 34bb3a99a..000000000 --- a/db/migrate/20130925000001_create_activity_stream.rb +++ /dev/null @@ -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 diff --git a/db/migrate/20131102000000_change_user2.rb b/db/migrate/20131102000000_change_user2.rb deleted file mode 100644 index 013a2ed12..000000000 --- a/db/migrate/20131102000000_change_user2.rb +++ /dev/null @@ -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 diff --git a/db/migrate/20140823000001_update_recent_viewed_create_object_lookup.rb b/db/migrate/20140823000001_update_recent_viewed_create_object_lookup.rb deleted file mode 100644 index 85a721de8..000000000 --- a/db/migrate/20140823000001_update_recent_viewed_create_object_lookup.rb +++ /dev/null @@ -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 \ No newline at end of file diff --git a/db/migrate/20140823000002_update_activity_stream_object_lookup.rb b/db/migrate/20140823000002_update_activity_stream_object_lookup.rb deleted file mode 100644 index 7dae9a53b..000000000 --- a/db/migrate/20140823000002_update_activity_stream_object_lookup.rb +++ /dev/null @@ -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 diff --git a/db/migrate/20140824000001_update_activity_stream_create_type_lookup.rb b/db/migrate/20140824000001_update_activity_stream_create_type_lookup.rb deleted file mode 100644 index 415c9c487..000000000 --- a/db/migrate/20140824000001_update_activity_stream_create_type_lookup.rb +++ /dev/null @@ -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