运行cmd时出错<rake db:migrate =“”> - “找不到'primary'的连接池”

时间:2017-09-10 21:30:13

标签: ruby sqlite activerecord migration sinatra

我正在尝试为我的sinatra应用程序设置一个SQLite Db,并且遇到了一个我无法弄清楚的错误。我查了相关的问题,但没有一个有帮助。

到目前为止,我已经bundle exec rake db:create_migration NAME=create_budget了 这在我的db文件夹中创建了一个迁移。

但是当我运行bundle exec rake db:migrate时,我收到以下错误消息:

ActiveRecord::ConnectionNotEstablished: No connection pool with 'primary' found.

我正在关注教程https://learn.co/lessons/sinatra-activerecord-setup

database.yml - 说明没有说创建这个,但在研究错误时,这似乎不断出现。这对我来说仍然是一种神奇的学习,所以我不确定activerecord是否需要这样做。

 # SQLite version 3.x
#   gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
  adapter: sqlite3
  database: db/development.sqlite3
  pool: 5
  timeout: 5000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: sqlite3
  database: db/test.sqlite3
  pool: 5
  timeout: 5000

production:
  adapter: sqlite3
  database: db/production.sqlite3
  pool: 5
  timeout: 5000

迁移:使用db:create_migration

创建
# Database Migration
class CreateBudget < ActiveRecord::Migration[5.1]
  def change
    create_table :budget do |t|
      t.string :description
      t.string :amount
    end
  end
end

的Gemfile:

# frozen_string_literal: true

source 'https://rubygems.org'

git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }

# gem "rails"

gem 'activerecord'
gem 'rake'
gem 'require_all'
gem 'sinatra'
gem 'sinatra-activerecord'
gem 'slim'
gem 'thin'

group :development do
  gem 'pry'
  gem 'shotgun'
  gem 'sqlite3'
  gem 'tux'
end

文件结构 - 不确定这是否有用

FilePath

1 个答案:

答案 0 :(得分:0)

plt.autoscale()