Search
 
SCRIPT & CODE EXAMPLE
 

RUBY

create_enum in rails 7

# db/migrate/20131220144913_create_articles.rb
def up
  create_enum :article_status, ["draft", "published"]

  create_table :articles do |t|
    t.enum :status, enum_type: :article_status, default: "draft", null: false
  end
end

# There's no built in support for dropping enums, but you can do it manually.
# You should first drop any table that depends on them.
def down
  drop_table :articles

  execute <<-SQL
    DROP TYPE article_status;
  SQL
end
Comment

PREVIOUS NEXT
Code Example
Ruby :: heroku run rails c 
Ruby :: rails cors allow all 
Ruby :: ruby merge array of hashes into one hash 
Ruby :: droptable rails 
Ruby :: text_field_tag placeholder rails 
Ruby :: ruby push array 
Ruby :: run Rspec 
Ruby :: helper path outside view 
Ruby :: get all the associations of a rails model 
Ruby :: ruby refinement include module 
Ruby :: run ruby script 
Ruby :: rails if else assignment one liner 
Ruby :: ruby array of strings 
Ruby :: rails destroy something from db 
Ruby :: gem file permission error for ubuntu rails 
Ruby :: ruby how to filter through excel 
Ruby :: ruby named parameters 
Ruby :: pick element from array that is part of params hash 
Ruby :: location of a string ruby 
Ruby :: sudo text logs 
Ruby :: rspec log to console 
Ruby :: print in rails 
Ruby :: ruby check if string is integer 
R :: r - remove scientific notations 
R :: how to append in R list 
R :: merge several data frames in r 
R :: ggplot - blank title of axis 
R :: how to extract p value from lm in r 
R :: how to use ifelse in r 
R :: how to throw an error in R 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =