質問編集履歴

3

マイグレーションファイルのソースコードを追記しました。

2020/11/02 22:14

投稿

aka_aka
aka_aka

スコア11

test CHANGED
File without changes
test CHANGED
@@ -366,16 +366,6 @@
366
366
 
367
367
  /usr/local/bundle/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:200:in `block in execute'
368
368
 
369
- /usr/local/bundle/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract_adapter.rb:722:in `block (2 levels) in log'
370
-
371
- /usr/local/bundle/gems/activesupport-6.0.3.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
372
-
373
- /usr/local/bundle/gems/activesupport-6.0.3.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
374
-
375
- /usr/local/bundle/gems/activesupport-6.0.3.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
376
-
377
- /usr/local/bundle/gems/activesupport-6.0.3.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
378
-
379
369
 
380
370
 
381
371
  〜中略〜
@@ -410,7 +400,39 @@
410
400
 
411
401
  ```
412
402
 
413
-
403
+ 11/03
404
+
405
+ 20201030080618_create_post_bs.rb のソースコード記載しました。
406
+
407
+ ```20201030080618_create_post_bs.rb
408
+
409
+ class CreatePostBs < ActiveRecord::Migration[6.0]
410
+
411
+ def change
412
+
413
+ create_table :post_bs do |t|
414
+
415
+ t.references :user,foreign_key: true
416
+
417
+ t.string :title,null: false
418
+
419
+ t.string :place,null: false
420
+
421
+ t.string :brand,null: false
422
+
423
+ t.text :story,null: false
424
+
425
+ t.text :evidence,null: false
426
+
427
+ t.timestamps
428
+
429
+ end
430
+
431
+ end
432
+
433
+ end
434
+
435
+ ```
414
436
 
415
437
 
416
438
 

2

試したことの追加

2020/11/02 22:14

投稿

aka_aka
aka_aka

スコア11

test CHANGED
File without changes
test CHANGED
@@ -280,6 +280,140 @@
280
280
 
281
281
 
282
282
 
283
+ ###追記
284
+
285
+ 下記を追加で行いました。
286
+
287
+ ・環境を指定してdb:migrateをしたところ、途中からエラーが発生しました。
288
+
289
+
290
+
291
+ ```
292
+
293
+ $ docker-compose exec web rails db:migrate RAILS_ENV=development
294
+
295
+
296
+
297
+ == 20201023085758 DeviseCreateUsers: migrating ================================
298
+
299
+ -- create_table(:users)
300
+
301
+ -> 0.0416s
302
+
303
+ -- add_index(:users, :email, {:unique=>true})
304
+
305
+ -> 0.0420s
306
+
307
+ -- add_index(:users, :reset_password_token, {:unique=>true})
308
+
309
+ -> 0.0404s
310
+
311
+ == 20201023085758 DeviseCreateUsers: migrated (0.1245s) =======================
312
+
313
+
314
+
315
+ == 20201024235341 CreateActiveStorageTables: migrating ========================
316
+
317
+ -- create_table(:active_storage_blobs, {})
318
+
319
+ -> 0.0409s
320
+
321
+ -- create_table(:active_storage_attachments, {})
322
+
323
+ -> 0.0411s
324
+
325
+ == 20201024235341 CreateActiveStorageTables: migrated (0.0821s) ===============
326
+
327
+
328
+
329
+ == 20201026020750 CreatePostCs: migrating =====================================
330
+
331
+ -- create_table(:post_cs)
332
+
333
+ -> 0.0455s
334
+
335
+ == 20201026020750 CreatePostCs: migrated (0.0456s) ============================
336
+
337
+
338
+
339
+ == 20201030080618 CreatePostBs: migrating =====================================
340
+
341
+ -- create_table(:post_bs)
342
+
343
+ rails aborted!
344
+
345
+ StandardError: An error has occurred, all later migrations canceled:
346
+
347
+
348
+
349
+ Mysql2::Error: Tablespace '`mybest_development`.`post_bs`' exists.
350
+
351
+ /usr/local/bundle/gems/mysql2-0.5.3/lib/mysql2/client.rb:131:in `_query'
352
+
353
+ /usr/local/bundle/gems/mysql2-0.5.3/lib/mysql2/client.rb:131:in `block in query'
354
+
355
+ /usr/local/bundle/gems/mysql2-0.5.3/lib/mysql2/client.rb:130:in `handle_interrupt'
356
+
357
+ /usr/local/bundle/gems/mysql2-0.5.3/lib/mysql2/client.rb:130:in `query'
358
+
359
+ /usr/local/bundle/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:201:in `block (2 levels) in execute'
360
+
361
+ /usr/local/bundle/gems/activesupport-6.0.3.4/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
362
+
363
+ /usr/local/bundle/gems/activesupport-6.0.3.4/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
364
+
365
+ /usr/local/bundle/gems/activesupport-6.0.3.4/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
366
+
367
+ /usr/local/bundle/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:200:in `block in execute'
368
+
369
+ /usr/local/bundle/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract_adapter.rb:722:in `block (2 levels) in log'
370
+
371
+ /usr/local/bundle/gems/activesupport-6.0.3.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
372
+
373
+ /usr/local/bundle/gems/activesupport-6.0.3.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
374
+
375
+ /usr/local/bundle/gems/activesupport-6.0.3.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
376
+
377
+ /usr/local/bundle/gems/activesupport-6.0.3.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
378
+
379
+
380
+
381
+ 〜中略〜
382
+
383
+
384
+
385
+ /usr/local/bundle/gems/spring-2.1.1/lib/spring/client/rails.rb:28:in `load'
386
+
387
+ /usr/local/bundle/gems/spring-2.1.1/lib/spring/client/rails.rb:28:in `call'
388
+
389
+ /usr/local/bundle/gems/spring-2.1.1/lib/spring/client/command.rb:7:in `call'
390
+
391
+ /usr/local/bundle/gems/spring-2.1.1/lib/spring/client.rb:30:in `run'
392
+
393
+ /usr/local/bundle/gems/spring-2.1.1/bin/spring:49:in `<top (required)>'
394
+
395
+ /usr/local/bundle/gems/spring-2.1.1/lib/spring/binstub.rb:11:in `load'
396
+
397
+ /usr/local/bundle/gems/spring-2.1.1/lib/spring/binstub.rb:11:in `<top (required)>'
398
+
399
+ /myapp/bin/spring:15:in `<top (required)>'
400
+
401
+ bin/rails:3:in `load'
402
+
403
+ bin/rails:3:in `<main>'
404
+
405
+ Tasks: TOP => db:migrate
406
+
407
+ (See full trace by running task with --trace)
408
+
409
+
410
+
411
+ ```
412
+
413
+
414
+
415
+
416
+
283
417
  コンテナを新しく建てても内容は変わらず・・・。
284
418
 
285
419
  もしこの状況が理解できる方がいらっしゃいましたらぜひ教えて下さい!

1

タイトルの編集を行いました。

2020/11/02 08:27

投稿

aka_aka
aka_aka

スコア11

test CHANGED
@@ -1 +1 @@
1
- dockerにてrails db:migrateを行いたい
1
+ docker環境】rails db:migrate時のエラーの対処法
test CHANGED
File without changes