about summary refs log tree commit diff stats
path: root/db/migrate/20180704125527_add_blog_drafts.rb
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrate/20180704125527_add_blog_drafts.rb')
-rw-r--r--db/migrate/20180704125527_add_blog_drafts.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/db/migrate/20180704125527_add_blog_drafts.rb b/db/migrate/20180704125527_add_blog_drafts.rb new file mode 100644 index 0000000..07c5078 --- /dev/null +++ b/db/migrate/20180704125527_add_blog_drafts.rb
@@ -0,0 +1,17 @@
1class AddBlogDrafts < ActiveRecord::Migration[5.1]
2 def change
3 add_column :blogs, :published, :boolean, null: false, default: false
4 add_column :blogs, :published_at, :datetime, null: true
5
6 reversible do |dir|
7 dir.up do
8 Blog.all.each do |blog|
9 blog.published = true
10 blog.published_at = blog.created_at
11
12 blog.save!
13 end
14 end
15 end
16 end
17end