Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Ensure required columns can't take null values

  • Loading branch information...
commit dd390b95378cf985f642e0696f4e391e8c06daa1 1 parent 2a89131
@mistydemeo authored
Showing with 21 additions and 0 deletions.
  1. +21 −0 db/migrate/20120814034005_specify_not_null.rb
View
21 db/migrate/20120814034005_specify_not_null.rb
@@ -0,0 +1,21 @@
+class SpecifyNotNull < ActiveRecord::Migration
+ def up
+ [:name,:item,:location,:description,:kind,:public_id].each do |column|
+ change_column :items, column, :string, :null => false
+ end
+ change_column :posts, :created_on, :datetime, :null => false
+ change_column :posts, :poster_id, :integer, :null => false
+ change_column :posts, :text, :text, :null => false
+ change_column :posters, :name, :string, :null => false
+ end
+
+ def down
+ [:name,:item,:location,:description,:kind,:public_id].each do |column|
+ change_column :items, column, :string, :null => true
+ end
+ change_column :posts, :created_on, :datetime, :null => true
+ change_column :posts, :poster_id, :integer, :null => true
+ change_column :posts, :text, :text, :null => true
+ change_column :posters, :name, :string, :null => true
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.