20120101000030_create_storage.rb 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. class CreateStorage < ActiveRecord::Migration
  2. def up
  3. create_table :stores do |t|
  4. t.references :store_object, :null => false
  5. t.references :store_file, :null => false
  6. t.column :o_id, :integer, :limit => 8, :null => false
  7. t.column :preferences, :string, :limit => 2500, :null => true
  8. t.column :size, :string, :limit => 50, :null => true
  9. t.column :filename, :string, :limit => 250, :null => false
  10. t.column :created_by_id, :integer, :null => false
  11. t.timestamps
  12. end
  13. add_index :stores, [:store_object_id, :o_id]
  14. create_table :store_objects do |t|
  15. t.column :name, :string, :limit => 250, :null => false
  16. t.column :note, :string, :limit => 250, :null => true
  17. t.timestamps
  18. end
  19. add_index :store_objects, [:name], :unique => true
  20. create_table :store_files do |t|
  21. t.column :data, :binary, :limit => 200.megabytes, :null => true
  22. t.column :md5, :string, :limit => 60, :null => false
  23. t.timestamps
  24. end
  25. add_index :store_files, [:md5], :unique => true
  26. end
  27. def down
  28. drop_table :stores
  29. drop_table :store_objects
  30. drop_table :store_files
  31. end
  32. end