Last active
December 12, 2015 00:08
-
-
Save johanb/4681127 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def change | |
create_table :ingredients do |t| | |
t.integer :quantity, default: 0, null: false | |
t.timestamps | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def change | |
create_table :ingredients do |t| | |
t.integer :quantity, default: 1, null: false | |
t.timestamps | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_column :ingredients, :quantity, :integer, :default => 1, :null => false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
change_column_null :ingredients, :quantity, false, 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading development environment (Rails 3.2.11) | |
>> ingredient = Ingredient.new | |
=> #<Ingredient id: nil, product_id: nil, quantity: nil, unit_id: nil, recipe_id: nil, created_at: nil, updated_at: nil> | |
>> ingredient.quantity | |
=> nil | |
>> ingredient.save | |
(0.2ms) BEGIN | |
SQL (10.9ms) INSERT INTO "ingredients" ("created_at", "product_id", "quantity", "recipe_id", "unit_id", "updated_at") VALUES ($1, $2, $3, $4, $5, $6) RETURNING "id" [["created_at", Thu, 31 Jan 2013 09:35:25 CET +01:00], ["product_id", nil], ["quantity", nil], ["recipe_id", nil], ["unit_id", nil], ["updated_at", Thu, 31 Jan 2013 09:35:25 CET +01:00]] | |
(1.7ms) COMMIT | |
=> true | |
>> ingredient = Ingredient.last | |
Ingredient Load (1.0ms) SELECT "ingredients".* FROM "ingredients" ORDER BY "ingredients"."id" DESC LIMIT 1 | |
=> #<Ingredient id: 1, product_id: nil, quantity: nil, unit_id: nil, recipe_id: nil, created_at: "2013-01-31 08:35:25", updated_at: "2013-01-31 08:35:25"> | |
>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm an idiot. rake db:reset does not run migrations, just loads schema.rb.