20120101000090_create_template.rb 883 B

1234567891011121314151617181920212223242526
  1. class CreateTemplate < ActiveRecord::Migration
  2. def up
  3. create_table :templates do |t|
  4. t.references :user, :null => true
  5. t.column :name, :string, :limit => 250, :null => false
  6. t.column :options, :string, :limit => 2500, :null => false
  7. t.column :updated_by_id, :integer, :null => false
  8. t.column :created_by_id, :integer, :null => false
  9. t.timestamps
  10. end
  11. add_index :templates, [:user_id]
  12. add_index :templates, [:name]
  13. create_table :templates_groups, :id => false do |t|
  14. t.integer :template_id
  15. t.integer :group_id
  16. end
  17. add_index :templates_groups, [:template_id]
  18. add_index :templates_groups, [:group_id]
  19. end
  20. def down
  21. drop_table :templates_groups
  22. drop_table :templates
  23. end
  24. end