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

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

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

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

Q&A

解決済

3回答

1179閲覧

デプロイでエラーが発生しました

HONEYyy

総合スコア1

Ruby on Rails 5

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

0グッド

0クリップ

投稿2023/01/02 23:38

編集2023/01/03 05:08

renderでアプリをデプロイしようとすると「PG::DuplicateTable: ERROR: relation "orders" already exists」というエラーが発生してしまいます。

検索してみると、「ordersテーブルは既にある」というという警告だとわかりました。

ですがordersテーブルはひとつしかつ作っていなかったのでうまくよ読み込みが出来ていないと思い、「rails db:migrate:reset」と、データベースを作り直そうと思い rails db:drop→rails db:create→rails db:migrateを順に行い、確実に複数のordersテーブルが存在しないようにしたのですがこれでも同じエラーメッセージが帰ってきました。

他にか解決策等あればお願い致しますm(_ _)m

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

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

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

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

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

winterboum

2023/01/03 00:48

情報が断片過ぎて分かりません。 drop→create→migrate の手順とその時のレスポンスを「質問欄を編集して」載せてください。 コメントには載せないで
guest

回答3

0

自己解決

マイグレーションが更新できるよう書き換えたら直りました

投稿2023/01/13 22:50

HONEYyy

総合スコア1

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

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

0

renderでアプリをデプロイ

初めてのデプロイで躓いているのであれば、既存のDB及びアプリを削除して、もう一度、最初からデプロイするとうまくいくことが多い気がします。
もし上記でうまくいかなければ、再度、コードを見直すと良いかと思います。

投稿2023/01/04 06:41

no1knows

総合スコア3365

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

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

0

マイグレーションファイルで orders を二回作る内容が含まれてませんか?

投稿2023/01/03 09:42

yuma.inaura

総合スコア1453

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

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

HONEYyy

2023/01/03 12:07

yuma.inaura

2023/01/03 12:19

画像だと厳しいのでコードはテキストで載せていただければと
HONEYyy

2023/01/03 13:33

class DeviseCreateUsers < ActiveRecord::Migration[6.0] def change create_table :users do |t| ## Database authenticatable t.string :nickname, null: false t.string :last_name, null: false t.string :first_name, null: false t.string :last_name_kana, null: false t.string :first_name_kana, null: false t.string :email, null: false, default: "" t.string :encrypted_password, null: false, default: "" t.date :birth_day, null: false ## Recoverable t.string :reset_password_token t.datetime :reset_password_sent_at ## Rememberable t.datetime :remember_created_at ## Trackable # t.integer :sign_in_count, default: 0, null: false # t.datetime :current_sign_in_at # t.datetime :last_sign_in_at # t.string :current_sign_in_ip # t.string :last_sign_in_ip ## Confirmable # t.string :confirmation_token # t.datetime :confirmed_at # t.datetime :confirmation_sent_at # t.string :unconfirmed_email # Only if using reconfirmable ## Lockable # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts # t.string :unlock_token # Only if unlock strategy is :email or :both # t.datetime :locked_at t.timestamps null: false end add_index :users, :email, unique: true add_index :users, :reset_password_token, unique: true # add_index :users, :confirmation_token, unique: true # add_index :users, :unlock_token, unique: true end end class CreateItems < ActiveRecord::Migration[6.0] def change create_table :items do |t| t.references :user, null: false, foreign_key: true t.string :name, null: false t.text :description, null: false t.integer :category_id, null: false t.integer :item_status_id, null: false t.integer :shopping_cost_id, null: false t.integer :prefecture_id, null: false t.integer :shopping_date_id, null: false t.integer :price, null: false t.timestamps end end end class CreateActiveStorageTables < ActiveRecord::Migration[5.2] def change create_table :active_storage_blobs do |t| t.string :key, null: false t.string :filename, null: false t.string :content_type t.text :metadata t.bigint :byte_size, null: false t.string :checksum, null: false t.datetime :created_at, null: false t.index [ :key ], unique: true end create_table :active_storage_attachments do |t| t.string :name, null: false t.references :record, null: false, polymorphic: true, index: false t.references :blob, null: false t.datetime :created_at, null: false t.index [ :record_type, :record_id, :name, :blob_id ], name: "index_active_storage_attachments_uniqueness", unique: true t.foreign_key :active_storage_blobs, column: :blob_id end end end class CreateOrders < ActiveRecord::Migration[6.0] def change create_table :orders do |t| t.references :user, null: false, foreign_key: true t.references :item, null: false, foreign_key: true t.timestamps end end end class CreateAddresses < ActiveRecord::Migration[6.0] def change create_table :addresses do |t| t.string :postal_code, null: false t.string :city, null: false t.string :address, null: false t.string :building t.string :phone_number, null: false t.integer :prefecture_id, null: false t.references :order, null: false, foreign_key: true t.timestamps end end end 失礼致しました
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問