Guest User

Untitled

a guest
Jul 21st, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. class CreateCategories < ActiveRecord::Migration
  2. def up
  3. create_table :categories do |t|
  4. t.integer :parent_id
  5. t.string :title, :null => false
  6. end
  7. execute('CREATE UNIQUE INDEX ix_categories_root_title ON categories (title) WHERE parent_id IS NULL')
  8. end
  9. def down
  10. drop_table :categories
  11. end
  12. end
  13.  
  14. ActiveRecord::Schema.define(:version => 20110808161830) do
  15. create_table "categories", :force => true do |t|
  16. t.integer "parent_id"
  17. t.string "title", :null => false
  18. end
  19. add_index "categories", ["title"], :name => "ix_categories_root_title", :unique => true
  20. end
  21.  
  22. config.active_record.schema_format = :sql
Add Comment
Please, Sign In to add comment