我使用迁移文件在rails应用程序中创建了一个名为Flowlogs的表。我也将数据馈入了Rails控制台中的该表。突然,当我尝试在Rails控制台中手动输入数据时,我得到了错误。
我创建了一个名为“ flowlogs”的表,该表中有两列,名称分别为vpc_id和flowlog_id。 我已经登录到Rails控制台,并给出了a = Flowlogs.new(),然后给出了a.vpc_id =“ 1234”和a.flowlog_id =“ a1234”,最后给出了a.save。这已成功工作,并且通过使用命令Flowlogs.all对我进行了交叉检查。它显示了输出。但是过了一段时间,当我登录控制台并提供Flowlogs.all时,它一直抛出错误。
最重要的是,当我登录mysql控制台并检查是否有一个包含我在rails控制台中手动输入的数据的表时
我的数据库名称是Fusion。
Flowlog Load (1.4ms) SELECT `flowlog`.* FROM `flowlog`
Hirb Error: Mysql2::Error: Table 'fusion.flowlog' doesn't exist: SELECT `flowlog`.* FROM `flowlog`
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/mysql2-0.4.10/lib/mysql2/client.rb:120:in `_query'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/mysql2-0.4.10/lib/mysql2/client.rb:120:in `block in query'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/mysql2-0.4.10/lib/mysql2/client.rb:119:in `handle_interrupt'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/mysql2-0.4.10/lib/mysql2/client.rb:119:in `query'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:305:in `block in execute'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract_adapter.rb:472:in `block in log'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/activesupport-4.2.6/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract_adapter.rb:466:in `log'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:305:in `execute'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/activerecord-4.2.6/lib/active_record/connection_adapters/mysql2_adapter.rb:231:in `execute'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/activerecord-4.2.6/lib/active_record/connection_adapters/mysql2_adapter.rb:235:in `exec_query'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/database_statements.rb:356:in `select'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/database_statements.rb:32:in `select_all'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/query_cache.rb:70:in `select_all'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/activerecord-4.2.6/lib/active_record/querying.rb:39:in `find_by_sql'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/activerecord-4.2.6/lib/active_record/relation.rb:639:in `exec_queries'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/activerecord-4.2.6/lib/active_record/relation.rb:515:in `load'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/activerecord-4.2.6/lib/active_record/relation.rb:243:in `to_a'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/activerecord-4.2.6/lib/active_record/relation/delegation.rb:46:in `to_ary'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/hirb-0.7.3/lib/hirb/formatter.rb:88:in `Array'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/hirb-0.7.3/lib/hirb/formatter.rb:88:in `determine_output_class'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/hirb-0.7.3/lib/hirb/formatter.rb:53:in `format_output'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/hirb-0.7.3/lib/hirb/view.rb:205:in `render_output'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/hirb-0.7.3/lib/hirb/view.rb:123:in `view_output'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/hirb-0.7.3/lib/hirb/view.rb:201:in `view_or_page_output'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/hirb-0.7.3/lib/hirb/view.rb:187:in `output_value'
/Users/masettya/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/irb.rb:490:in `block (2 levels) in eval_input'
/Users/masettya/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/irb.rb:623:in `signal_status'
/Users/masettya/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/irb.rb:486:in `block in eval_input'
/Users/masettya/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/irb/ruby-lex.rb:246:in `block (2 levels) in each_top_level_statement'
/Users/masettya/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/irb/ruby-lex.rb:232:in `loop'
/Users/masettya/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/irb/ruby-lex.rb:232:in `block in each_top_level_statement'
/Users/masettya/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/irb/ruby-lex.rb:231:in `catch'
/Users/masettya/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/irb/ruby-lex.rb:231:in `each_top_level_statement'
/Users/masettya/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/irb.rb:485:in `eval_input'
/Users/masettya/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/irb.rb:395:in `block in start'
/Users/masettya/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/irb.rb:394:in `catch'
/Users/masettya/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/irb.rb:394:in `start'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/railties-4.2.6/lib/rails/commands/console.rb:110:in `start'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/railties-4.2.6/lib/rails/commands/console.rb:9:in `start'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:68:in `console'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/railties-4.2.6/lib/rails/commands.rb:17:in `<top (required)>'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `block in require'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
/Users/masettya/fusion_app/bin/rails:9:in `<top (required)>'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `load'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `block in load'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
/Users/masettya/.rvm/gems/ruby-2.3.1/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `load'
/Users/masettya/.rvm/rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Users/masettya/.rvm/rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:in `require'
-e:1:in `<main>'
这是我的迁移文件
class CreateFlowlogs < ActiveRecord::Migration
def change
create_table :flowlogs do |t|
t.string :account_name
t.string :region
t.string :vpc_id
t.string :flowlog_id
t.boolean :status
end
end
end
这是schema.rb文件
create_table "account_master", force: :cascade do |t|
t.string "name", limit: 52, null: false
t.string "alias_name", limit: 52, null: false
t.string "owner", limit: 26, null: false
t.string "mail_contact", limit: 100
t.string "dl_email", limit: 50
t.string "root_user", limit: 32, null: false
t.string "team", limit: 32
t.string "contact_no", limit: 15
t.string "email", limit: 50
t.string "del_flg", limit: 1, default: "", null: false
t.date "created_on", null: false
t.string "created_by", limit: 50
t.date "modified_on"
t.string "modified_by", limit: 50
t.string "account_type", limit: 50
t.string "ssl_account", limit: 20
end
create_table "admin_authentication_users", force: :cascade do |t|
t.string "email", limit: 255, default: "", null: false
t.string "encrypted_password", limit: 255, default: "", null: false
t.integer "sign_in_count", limit: 4, default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip", limit: 255
t.string "last_sign_in_ip", limit: 255
t.datetime "created_at"
t.datetime "updated_at"
t.string "uid", limit: 255
t.text "all_details", limit: 65535
t.string "otp_secret_key", limit: 255
t.boolean "qr_not_required", default: false, null: false
t.boolean "active", default: false, null: false
t.boolean "deleted", default: false, null: false
end
add_index "admin_authentication_users", ["email"], name: "index_admin_authentication_users_on_email", unique: true, using: :btree
create_table "employee_shift", force: :cascade do |t|
t.string "emp_id", limit: 30
t.string "session", limit: 50
t.string "created_by", limit: 100
t.datetime "created_on"
t.date "session_date"
t.string "emp_name", limit: 200
t.string "updated_by", limit: 200
t.datetime "updated_on"
end
create_table "flowlogs", force: :cascade do |t|
t.string "account_name", limit: 255
t.string "region", limit: 255
t.string "vpc_id", limit: 255
t.string "flowlog_id", limit: 255
t.boolean "status"
end
create_table "tests", force: :cascade do |t|
t.string "function", limit: 255
t.string "description", limit: 255
end
create_table "updates", primary_key: "reference_id", force: :cascade do |t|
t.string "created_by", limit: 200, default: "", null: false
t.datetime "created_on", null: false
t.string "subject", limit: 2000, default: "", null: false
t.text "body_content", limit: 65535, null: false
t.string "status", limit: 20, default: "", null: false
t.string "creted_by_id", limit: 100, default: "", null: false
t.string "account", limit: 100, default: "", null: false
t.string "archive_by", limit: 200
t.datetime "archive_on"
t.string "archive_by_id", limit: 200
end
end