質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

コマンド

コマンドとは特定のタスクを行う為に、コンピュータープログラムへ提示する指示文です。多くの場合、コマンドはShellやcmdようなコマンドラインインターフェイスに対する指示文を指します。

コマンドプロンプト

コマンドプロンプト(cmd.exe)はMicrosoftによって提供されているコマンドラインインタプリタです。OS/2・Windows CE・Windows NTで使用可能です。

データベース

データベースとは、データの集合体を指します。また、そのデータの集合体の共用を可能にするシステムの意味を含めます

Q&A

0回答

827閲覧

heroku run rails db:migrateが通らない

yukikiti

総合スコア1

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

コマンド

コマンドとは特定のタスクを行う為に、コンピュータープログラムへ提示する指示文です。多くの場合、コマンドはShellやcmdようなコマンドラインインターフェイスに対する指示文を指します。

コマンドプロンプト

コマンドプロンプト(cmd.exe)はMicrosoftによって提供されているコマンドラインインタプリタです。OS/2・Windows CE・Windows NTで使用可能です。

データベース

データベースとは、データの集合体を指します。また、そのデータの集合体の共用を可能にするシステムの意味を含めます

0グッド

1クリップ

投稿2020/10/12 01:33

編集2020/10/12 07:15

現在railsでWEBアプリを作成し、Herokuにデプロイしているのですが、本番環境でエラーが出たので、

見直したところ、

heroku run rails db:migrate

した際に以下のエラーが出ている事を見つけました。

heroku run rails db:migrate Running rails db:migrate on ⬢ teterako... up, run.2755 (Free) D, [2020-10-11T13:11:01.732435 #4] DEBUG -- : (1.2ms) SELECT pg_try_advisory_lock(3591403873564692675) D, [2020-10-11T13:11:01.752278 #4] DEBUG -- : (2.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC I, [2020-10-11T13:11:01.753656 #4] INFO -- : Migrating to ChangeDataUserIdToPosts (20200930145224) D, [2020-10-11T13:11:01.757006 #4] DEBUG -- : (1.1ms) BEGIN == 20200930145224 ChangeDataUserIdToPosts: migrating ========================== -- change_column(:posts, :title, :integer) D, [2020-10-11T13:11:01.759452 #4] DEBUG -- : (2.0ms) ALTER TABLE "posts" ALTER COLUMN "title" TYPE integer D, [2020-10-11T13:11:01.760793 #4] DEBUG -- : (1.1ms) ROLLBACK D, [2020-10-11T13:11:01.762427 #4] DEBUG -- : (1.3ms) SELECT pg_advisory_unlock(3591403873564692675) rails aborted! StandardError: An error has occurred, this and all later migrations canceled: PG::DatatypeMismatch: ERROR: column "title" cannot be cast automatically to type integer HINT: You might need to specify "USING title::integer". : ALTER TABLE "posts" ALTER COLUMN "title" TYPE integer

以前にPostモデルのtitileカラムがなぜか数字しか出ず、データ型をtextからstringに変えたことが原因だと思い、Postモデルのtitileカラムを削除してみましたがこのエラーは消えず、、、

そして、新しくPostモデルに新しくtitleカラムをデータ型integerで追加してみましたがこのエラーは消えません。調べてみても原因がわからず、このエラーの解決法、原因を教えていただけたら幸いです。

よろしくお願いいたします。

db/schema.rb

1# This file is auto-generated from the current state of the database. Instead 2# of editing this file, please use the migrations feature of Active Record to 3# incrementally modify your database, and then regenerate this schema definition. 4# 5# Note that this schema.rb definition is the authoritative source for your 6# database schema. If you need to create the application database on another 7# system, you should be using db:schema:load, not running all the migrations 8# from scratch. The latter is a flawed and unsustainable approach (the more migrations 9# you'll amass, the slower it'll run and the greater likelihood for issues). 10# 11# It's strongly recommended that you check this file into your version control system. 12 13ActiveRecord::Schema.define(version: 2020_10_11_130211) do 14 15 create_table "likes", force: :cascade do |t| 16 t.integer "word_user_id" 17 t.integer "word_id" 18 t.datetime "created_at", null: false 19 t.datetime "updated_at", null: false 20 end 21 22 create_table "posts", force: :cascade do |t| 23 t.text "content" 24 t.string "url" 25 t.string "next_url" 26 t.string "class_type" 27 t.string "image_url" 28 t.string "user_id" 29 t.datetime "created_at", null: false 30 t.datetime "updated_at", null: false 31 t.string "taiwan_beginner_1" 32 t.string "taiwan_beginner_cleared" 33 t.text "posts_title" 34 t.integer "title" 35 end 36 37 create_table "taiwan_beginner_1_posts", force: :cascade do |t| 38 t.text "content" 39 t.datetime "created_at", null: false 40 t.datetime "updated_at", null: false 41 t.integer "user_id" 42 end 43 44 create_table "taiwanbeginner1posts", force: :cascade do |t| 45 t.text "content" 46 t.integer "user_id" 47 t.datetime "created_at", null: false 48 t.datetime "updated_at", null: false 49 end 50 51 create_table "users", force: :cascade do |t| 52 t.string "provider" 53 t.string "uid" 54 t.string "name" 55 t.string "email" 56 t.string "image" 57 t.string "oauth_token" 58 t.datetime "oauth_expires_at" 59 t.datetime "created_at", null: false 60 t.datetime "updated_at", null: false 61 t.string "taiwan_daily_conversation_purchased" 62 t.string "taiwan_beginner_cleared" 63 t.string "taiwan_intermediate_cleared" 64 t.string "taiwan_daily_conversation_cleared" 65 t.string "taiwan_before_studying_abroad_cleared" 66 t.string "taiwan_before_studying_abroad_purchased" 67 t.string "taiwan_beginner_1_cleared" 68 t.string "taiwan_beginner_2_cleared" 69 end 70 71 create_table "words", force: :cascade do |t| 72 t.string "word_type" 73 t.string "word_user_id" 74 t.string "content" 75 t.string "meaning" 76 t.string "pronunciation" 77 t.datetime "created_at", null: false 78 t.datetime "updated_at", null: false 79 end 80 81end 82

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

no1knows

2020/10/12 06:10

db/schema.rbを追記ください。
yukikiti

2020/10/12 07:15

ご回答ありがとうございます。 追記いたしました。よろしくお願いいたします。
no1knows

2020/10/12 09:22

Schemaファイルは問題ないようですが、エラーにあるとおりMigrating to ChangeDataUserIdToPosts (20200930145224)の前後で問題があるようです。 Post関連のmigrationファイルを追記いただく、またはテスト環境・本番環境、双方のDBを初期化できるなら下記の2からの作業手順に従っていただければデプロイできるかと思います。 https://teratail.com/questions/280067#reply-398726 質問とは全く関係ないですが、下記2つのカラムは何につかうのでしょうか? t.string "taiwan_beginner_1" t.string "taiwan_beginner_cleared"
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問