rake db:create
rake db:migrate
FATAL: role "ubuntu" does not exist
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:825:in `initialize'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:825:in `new'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:825:in `connect'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:542:in `initialize'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `new'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `postgresql_connection'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:440:in `new_connection'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:450:in `checkout_new_connection'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:421:in `acquire_connection'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:356:in `block in checkout'
/home/ubuntu/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:355:in `checkout'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block in connection'
/home/ubuntu/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in `connection'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:546:in `retrieve_connection'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_handling.rb:79:in `retrieve_connection'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_handling.rb:53:in `connection'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/tasks/postgresql_database_tasks.rb:8:in `connection'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/tasks/postgresql_database_tasks.rb:17:in `create'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/tasks/database_tasks.rb:72:in `create'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/tasks/database_tasks.rb:86:in `block in create_current'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/tasks/database_tasks.rb:182:in `block in each_current_configuration'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/tasks/database_tasks.rb:181:in `each'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/tasks/database_tasks.rb:181:in `each_current_configuration'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/tasks/database_tasks.rb:85:in `create_current'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/railties/databases.rake:20:in `block (2 levels) in <top (required)>'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/home/ubuntu/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/application.rb:149:in `invoke_task'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/application.rb:106:in `each'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/application.rb:106:in `block in top_level'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/application.rb:115:in `run_with_threads'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/application.rb:100:in `top_level'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/application.rb:78:in `block in run'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/bin/rake:23:in `load'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/bin/rake:23:in `<main>'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks:15:in `eval'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks:15:in `<main>'
Couldn't create database for {"adapter"=>"postgresql", "database"=>"my_data_base_development", "pool"=>5, "timeout"=>5000}
FATAL: role "ubuntu" does not exist
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:825:in `initialize'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:825:in `new'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:825:in `connect'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:542:in `initialize'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `new'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `postgresql_connection'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:440:in `new_connection'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:450:in `checkout_new_connection'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:421:in `acquire_connection'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:356:in `block in checkout'
/home/ubuntu/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:355:in `checkout'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block in connection'
/home/ubuntu/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in `connection'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:546:in `retrieve_connection'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_handling.rb:79:in `retrieve_connection'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_handling.rb:53:in `connection'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/tasks/postgresql_database_tasks.rb:8:in `connection'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/tasks/postgresql_database_tasks.rb:17:in `create'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/tasks/database_tasks.rb:72:in `create'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/tasks/database_tasks.rb:86:in `block in create_current'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/tasks/database_tasks.rb:182:in `block in each_current_configuration'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/tasks/database_tasks.rb:181:in `each'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/tasks/database_tasks.rb:181:in `each_current_configuration'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/tasks/database_tasks.rb:85:in `create_current'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/railties/databases.rake:20:in `block (2 levels) in <top (required)>'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/home/ubuntu/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/application.rb:149:in `invoke_task'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/application.rb:106:in `each'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/application.rb:106:in `block in top_level'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/application.rb:115:in `run_with_threads'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/application.rb:100:in `top_level'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/application.rb:78:in `block in run'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/bin/rake:23:in `load'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/bin/rake:23:in `<main>'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks:15:in `eval'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks:15:in `<main>'
Couldn't create database for {"adapter"=>"postgresql", "database"=>"my_data_base_test", "pool"=>5, "timeout"=>5000}
class Photo < ActiveRecord::Base
has_attached_file :image
end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'
gem 'bootstrap-sass', '2.3.2'
gem "paperclip", "~> 3.0"
gem "rake"
# Use sqlite3 as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
class CreatePhotos < ActiveRecord::Migration
def change
create_table :photos do |t|
t.timestamps
end
end
def self.up
add_column :photos, :image_file_name, :string
add_column :photos, :image_content_type, :string
add_column :photos, :image_file_size, :string
add_column :photos, :image_update_at, :string
end
def self.down
remove_column :photos, :image_file_name, :string
remove_column :photos, :image_content_type, :string
remove_column :photos, :image_file_size, :string
remove_column :photos, :image_update_at, :string
end
end
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
development:
adapter: postgresql
database: my_data_base_development
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: postgresql
database: my_data_base_test
pool: 5
timeout: 5000
production:
adapter: postgresql
database: my_data_base_production
pool: 5
timeout: 5000
你有办法让我的迁移工作吗?感谢的
您应该按照以下指南设置Postgres和Rails:
本教程的本节演示如何为Postgres设置用户:
设置Postgres为我们将在下一步中创建的Rails应用程序创建一个Postgres用户。为此,切换到Postgres用户:
create role myapp with createdb login password 'password1'
Python自带一个轻量级的关系型数据库SQLite。这一数据库使用SQL语言。SQLite作为后端数据库,可以搭配Python建网站,或者制作有数据存储需求的工具。SQLite还在其它领域有广泛的应用,比如HTML5和移动端。Python标准库中的sqlite3提供该数据库的接口。 我将创建一个简单的关系型数据库,为一个书店存储书的分类和价格。数据库中包含两个表:category用于记录分类,b
创建一个数据库 # sqlite3_createdb.py import os import sqlite3 db_filename = 'todo.db' db_is_new = not os.path.exists(db_filename) conn = sqlite3.connect(db_filename) if db_is_new: print('Need to crea
PostgreSQL 删除数据库可以用以下三种方式: 1、使用 DROP DATABASE SQL 语句来删除。 2、使用 dropdb 命令来删除。 3、使用 pgAdmin 工具。 注意:删除数据库要谨慎操作,一旦删除,所有信息都会消失。 DROP DATABASE 删除数据库 DROP DATABASE 会删除数据库的系统目录项并且删除包含数据的文件目录。 DROP DATABASE 只能由
上一章节我们讲了如何创建数据库,接下来我们来讨论如何去选择我们创建的数据库。 数据库的命令窗口 PostgreSQL 命令窗口中,我们可以命令提示符后面输入 SQL 语句: 使用 \l 用于查看已经存在的数据库: 接下来我们可以使用 \c + 数据库名 来进入数据库: 系统命令行窗口 在系统的命令行查看,我么可以在连接数据库后面添加数据库名来选择数据库: pgAdmin 工具 pgAdmin 工具
PostgreSQL 创建数据库可以用以下三种方式: 1、使用 CREATE DATABASE SQL 语句来创建。 2、使用 createdb 命令来创建。 3、使用 pgAdmin 工具。 CREATE DATABASE 创建数据库 CREATE DATABASE 命令需要在 PostgreSQL 命令窗口来执行,语法格式如下: 例如,我们创建一个 runoobdb 的数据库: created
这个代码不起作用。谁能告诉我在哪里可以找到用C#动态创建Postgresql数据库和表的例子? 数据库已创建,但我在创建表时遇到一个无声的失败。