Skip to content

Commit

Permalink
Contentテーブル作成
Browse files Browse the repository at this point in the history
  • Loading branch information
fukmaru committed Apr 29, 2019
1 parent 98881a1 commit 60d4ac8
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -41,6 +41,7 @@ group :development do
gem 'spring-watcher-listen', '~> 2.0.0'

gem 'foreman'
gem 'annotate'
end

group :test do
Expand Down
4 changes: 4 additions & 0 deletions Gemfile.lock
Expand Up @@ -44,6 +44,9 @@ GEM
tzinfo (~> 1.1)
addressable (2.6.0)
public_suffix (>= 2.0.2, < 4.0)
annotate (2.7.4)
activerecord (>= 3.2, < 6.0)
rake (>= 10.4, < 13.0)
archive-zip (0.12.0)
io-like (~> 0.3.0)
arel (9.0.0)
Expand Down Expand Up @@ -179,6 +182,7 @@ PLATFORMS
ruby

DEPENDENCIES
annotate
bootsnap (>= 1.1.0)
byebug
capybara (>= 2.15)
Expand Down
14 changes: 14 additions & 0 deletions app/models/content.rb
@@ -0,0 +1,14 @@
# == Schema Information
#
# Table name: contents
#
# id :bigint(8) not null, primary key
# body :text
# is_published :boolean
# title :string
# created_at :datetime not null
# updated_at :datetime not null
#

class Content < ApplicationRecord
end
11 changes: 11 additions & 0 deletions db/migrate/20190429022702_create_contents.rb
@@ -0,0 +1,11 @@
class CreateContents < ActiveRecord::Migration[5.2]
def change
create_table :contents do |t|
t.string :title
t.text :body
t.boolean :is_published

t.timestamps
end
end
end
26 changes: 26 additions & 0 deletions db/schema.rb
@@ -0,0 +1,26 @@
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2019_04_29_022702) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

create_table "contents", force: :cascade do |t|
t.string "title"
t.text "body"
t.boolean "is_published"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end

end
54 changes: 54 additions & 0 deletions lib/tasks/auto_annotate_models.rake
@@ -0,0 +1,54 @@
# NOTE: only doing this in development as some production environments (Heroku)
# NOTE: are sensitive to local FS writes, and besides -- it's just not proper
# NOTE: to have a dev-mode tool do its thing in production.
if Rails.env.development?
require 'annotate'
task :set_annotation_options do
# You can override any of these by setting an environment variable of the
# same name.
Annotate.set_defaults(
'routes' => 'false',
'position_in_routes' => 'before',
'position_in_class' => 'before',
'position_in_test' => 'before',
'position_in_fixture' => 'before',
'position_in_factory' => 'before',
'position_in_serializer' => 'before',
'show_foreign_keys' => 'true',
'show_complete_foreign_keys' => 'false',
'show_indexes' => 'true',
'simple_indexes' => 'false',
'model_dir' => 'app/models',
'root_dir' => '',
'include_version' => 'false',
'require' => '',
'exclude_tests' => 'false',
'exclude_fixtures' => 'false',
'exclude_factories' => 'false',
'exclude_serializers' => 'false',
'exclude_scaffolds' => 'true',
'exclude_controllers' => 'true',
'exclude_helpers' => 'true',
'exclude_sti_subclasses' => 'false',
'ignore_model_sub_dir' => 'false',
'ignore_columns' => nil,
'ignore_routes' => nil,
'ignore_unknown_models' => 'false',
'hide_limit_column_types' => 'integer,boolean',
'hide_default_column_types' => 'json,jsonb,hstore',
'skip_on_db_migrate' => 'false',
'format_bare' => 'true',
'format_rdoc' => 'false',
'format_markdown' => 'false',
'sort' => 'false',
'force' => 'false',
'classified_sort' => 'true',
'trace' => 'false',
'wrapper_open' => nil,
'wrapper_close' => nil,
'with_comment' => true
)
end

Annotate.load_tasks
end

0 comments on commit 60d4ac8

Please sign in to comment.