diff options
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20180704125527_add_blog_drafts.rb | 17 | ||||
-rw-r--r-- | db/schema.rb | 4 |
2 files changed, 20 insertions, 1 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 @@ | |||
1 | class 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 | ||
17 | end | ||
diff --git a/db/schema.rb b/db/schema.rb index 2ca0b58..d885500 100644 --- a/db/schema.rb +++ b/db/schema.rb | |||
@@ -10,7 +10,7 @@ | |||
10 | # | 10 | # |
11 | # It's strongly recommended that you check this file into your version control system. | 11 | # It's strongly recommended that you check this file into your version control system. |
12 | 12 | ||
13 | ActiveRecord::Schema.define(version: 20180702221133) do | 13 | ActiveRecord::Schema.define(version: 20180704125527) do |
14 | 14 | ||
15 | create_table "blogs", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin" do |t| | 15 | create_table "blogs", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin" do |t| |
16 | t.string "title" | 16 | t.string "title" |
@@ -18,6 +18,8 @@ ActiveRecord::Schema.define(version: 20180702221133) do | |||
18 | t.string "slug", null: false | 18 | t.string "slug", null: false |
19 | t.datetime "created_at", null: false | 19 | t.datetime "created_at", null: false |
20 | t.datetime "updated_at", null: false | 20 | t.datetime "updated_at", null: false |
21 | t.boolean "published", default: false, null: false | ||
22 | t.datetime "published_at" | ||
21 | end | 23 | end |
22 | 24 | ||
23 | create_table "ckeditor_assets", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin" do |t| | 25 | create_table "ckeditor_assets", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin" do |t| |