困っていること
初学者です。
docker上で、Ruby On Rails のアプリケーションを開発しています。
migration周りをいじっていたら、dbが壊れたようでにっちもさっちも行かなくなりました。。
dbはmysqlです。
rails db:drop
rails db:create
rails db:migrate
の順で一から作り直そうとしましたが、それでもダメで、、
rails aborted! ActiveRecord::StatementInvalid: Mysql2::Error: Got error 168 from storage engine: CREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL PRIMARY KEY) /usr/local/bundle/gems/mysql2-0.5.3/lib/mysql2/client.rb:131:in `_query' /usr/local/bundle/gems/mysql2-0.5.3/lib/mysql2/client.rb:131:in `block in query' /usr/local/bundle/gems/mysql2-0.5.3/lib/mysql2/client.rb:130:in `handle_interrupt' /usr/local/bundle/gems/mysql2-0.5.3/lib/mysql2/client.rb:130:in `query' /usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:187:in `block (2 levels) in execute' /usr/local/bundle/gems/activesupport-5.2.4.3/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads' /usr/local/bundle/gems/activesupport-5.2.4.3/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares' /usr/local/bundle/gems/activesupport-5.2.4.3/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads' /usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:186:in `block in execute' /usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log' /usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log' /usr/local/bundle/gems/activesupport-5.2.4.3/lib/active_support/notifications/instrumenter.rb:23:in `instrument' /usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log' /usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:185:in `execute' /usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/mysql/database_statements.rb:28:in `execute' /usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/abstract/schema_statements.rb:311:in `create_table' /usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/schema_migration.rb:29:in `create_table' /usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/migration.rb:1187:in `initialize' /usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/migration.rb:1036:in `new' /usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/migration.rb:1036:in `up' /usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/migration.rb:1011:in `migrate' /usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/tasks/database_tasks.rb:172:in `migrate' /usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/railties/databases.rake:60:in `block (2 levels) in <top (required)>' /usr/local/bundle/gems/railties-5.2.4.3/lib/rails/commands/rake/rake_command.rb:23:in `block in perform' /usr/local/bundle/gems/railties-5.2.4.3/lib/rails/commands/rake/rake_command.rb:20:in `perform' /usr/local/bundle/gems/railties-5.2.4.3/lib/rails/command.rb:48:in `invoke' /usr/local/bundle/gems/railties-5.2.4.3/lib/rails/commands.rb:18:in `<top (required)>' /usr/local/bundle/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require' /usr/local/bundle/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi' /usr/local/bundle/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register' /usr/local/bundle/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi' /usr/local/bundle/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require' /usr/local/bundle/gems/activesupport-5.2.4.3/lib/active_support/dependencies.rb:291:in `block in require' /usr/local/bundle/gems/activesupport-5.2.4.3/lib/active_support/dependencies.rb:257:in `load_dependency' /usr/local/bundle/gems/activesupport-5.2.4.3/lib/active_support/dependencies.rb:291:in `require' bin/rails:4:in `<main>' Caused by: Mysql2::Error: Got error 168 from storage engine /usr/local/bundle/gems/mysql2-0.5.3/lib/mysql2/client.rb:131:in `_query' /usr/local/bundle/gems/mysql2-0.5.3/lib/mysql2/client.rb:131:in `block in query' /usr/local/bundle/gems/mysql2-0.5.3/lib/mysql2/client.rb:130:in `handle_interrupt' /usr/local/bundle/gems/mysql2-0.5.3/lib/mysql2/client.rb:130:in `query' /usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:187:in `block (2 levels) in execute' /usr/local/bundle/gems/activesupport-5.2.4.3/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads' /usr/local/bundle/gems/activesupport-5.2.4.3/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares' /usr/local/bundle/gems/activesupport-5.2.4.3/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads' /usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:186:in `block in execute' /usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log' /usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log' /usr/local/bundle/gems/activesupport-5.2.4.3/lib/active_support/notifications/instrumenter.rb:23:in `instrument' /usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log' /usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:185:in `execute' /usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/mysql/database_statements.rb:28:in `execute' /usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/abstract/schema_statements.rb:311:in `create_table' /usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/schema_migration.rb:29:in `create_table' /usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/migration.rb:1187:in `initialize' /usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/migration.rb:1036:in `new' /usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/migration.rb:1036:in `up' /usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/migration.rb:1011:in `migrate' /usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/tasks/database_tasks.rb:172:in `migrate' /usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/railties/databases.rake:60:in `block (2 levels) in <top (required)>' /usr/local/bundle/gems/railties-5.2.4.3/lib/rails/commands/rake/rake_command.rb:23:in `block in perform' /usr/local/bundle/gems/railties-5.2.4.3/lib/rails/commands/rake/rake_command.rb:20:in `perform' /usr/local/bundle/gems/railties-5.2.4.3/lib/rails/command.rb:48:in `invoke' /usr/local/bundle/gems/railties-5.2.4.3/lib/rails/commands.rb:18:in `<top (required)>' /usr/local/bundle/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require' /usr/local/bundle/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi' /usr/local/bundle/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register' /usr/local/bundle/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi' /usr/local/bundle/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require' /usr/local/bundle/gems/activesupport-5.2.4.3/lib/active_support/dependencies.rb:291:in `block in require' /usr/local/bundle/gems/activesupport-5.2.4.3/lib/active_support/dependencies.rb:257:in `load_dependency' /usr/local/bundle/gems/activesupport-5.2.4.3/lib/active_support/dependencies.rb:291:in `require' bin/rails:4:in `<main>' Tasks: TOP => db:migrate
このようにエラーが出てしまいます。
完全にdbをリセットする方法は無いのでしょうか。。
#開発環境
ruby 2.5.3
rails 5.2.4
mysql 5.7
docker-compose.yml
version: '3' services: db: image: mysql:5.7 ports: - '2012:3306' environment: MYSQL_USER: root MYSQL_ROOT_PASSWORD: password volumes: - ./db/mysql/volumes:/var/lib/mysql web: image: rails:my_orav3 command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'" volumes: - .:/myapp environment: - TNS_ADMIN=./oracle_conf - TZ="Asia/Tokyo" - LANG=ja_JP.UTF-8 ports: - "2102:3000" depends_on: - db
よろしくお願いします。。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。