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ページで確認できます。
またクリップした質問に回答があった際、通知やメールを受け取ることができます。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
情報が断片過ぎて分かりません。
drop→create→migrate
の手順とその時のレスポンスを「質問欄を編集して」載せてください。
コメントには載せないで

回答3件
0
マイグレーションファイルで orders を二回作る内容が含まれてませんか?
投稿2023/01/03 09:42
総合スコア1453
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
https://i.gyazo.com/cb18359a9fe443f9fae307a8d2cfe371.png
https://i.gyazo.com/e46ae5b6c4f713f39e399b0b96af8903.png
https://i.gyazo.com/6e83a4f5a5c5ade117346c4699584979.png
https://i.gyazo.com/2bb92c859eabf82f5e9d9f0a6d268d77.png
https://i.gyazo.com/b560d8cb9988558cfdbf97f2a842337b.png
https://i.gyazo.com/740672ab6d046045d0808abb0ab201b9.png
見直してみたのですが、そのような記述にはなっていないように思えます。もし問題ありそうなファイル等ありましたらアドバイス等いただけたら嬉しいです
画像だと厳しいのでコードはテキストで載せていただければと
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
失礼致しました

あなたの回答
tips
太字
斜体
打ち消し線
見出し
引用テキストの挿入
コードの挿入
リンクの挿入
リストの挿入
番号リストの挿入
表の挿入
水平線の挿入
プレビュー
質問の解決につながる回答をしましょう。 サンプルコードなど、より具体的な説明があると質問者の理解の助けになります。 また、読む側のことを考えた、分かりやすい文章を心がけましょう。