20130925000001_create_activity_stream.rb 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. class CreateActivityStream < ActiveRecord::Migration
  2. def up
  3. create_table :activity_streams do |t|
  4. t.references :activity_stream_type, :null => false
  5. t.references :activity_stream_object, :null => false
  6. t.references :role, :null => true
  7. t.references :group, :null => true
  8. t.column :o_id, :integer, :null => false
  9. t.column :created_by_id, :integer, :null => false
  10. t.timestamps
  11. end
  12. add_index :activity_streams, [:o_id]
  13. add_index :activity_streams, [:created_by_id]
  14. add_index :activity_streams, [:role_id]
  15. add_index :activity_streams, [:group_id]
  16. add_index :activity_streams, [:created_at]
  17. add_index :activity_streams, [:activity_stream_object_id]
  18. add_index :activity_streams, [:activity_stream_type_id]
  19. create_table :activity_stream_types do |t|
  20. t.column :name, :string, :limit => 250, :null => false
  21. t.timestamps
  22. end
  23. add_index :activity_stream_types, [:name], :unique => true
  24. create_table :activity_stream_objects do |t|
  25. t.column :name, :string, :limit => 250, :null => false
  26. t.column :note, :string, :limit => 250, :null => true
  27. t.timestamps
  28. end
  29. add_index :activity_stream_objects, [:name], :unique => true
  30. end
  31. def down
  32. drop_table :activity_streams
  33. drop_table :activity_stream_objects
  34. drop_table :activity_stream_types
  35. end
  36. end