ridgepoleでtable追加していく
ridgepoleとは
rails g migration して。。。とかめんどくさい場合にとても使える
準備
Gemfileに下記追加
gem 'ridgepole'
bundle (install)
Schemafileをapp下に作成(ちゃんと先頭は大文字にすること) 音楽系のテーブルの場合下記な感じで記述
create_table "artists", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci" do |t| t.string "name", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["name"], name: "artists_on_name", using: :btree end create_table "songs", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci" do |t| t.integer "artist_id", null: false t.string "name", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["artist_id"], name: "songs_on_artist_id", using: :btree t.index ["name"], name: "songs_on_name", using: :btree end
あとは、
bundle exec ridgepole -c config/database.yml --apply -E development
で追加される