switch database to postgres

This commit is contained in:
2015-07-22 22:32:56 +08:00
parent 037c335f82
commit cf39c818a3
7 changed files with 115 additions and 41 deletions
+3 -7
View File
@@ -1,14 +1,10 @@
source 'https://ruby.taobao.org/'
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.3'
# Use sqlite3 as the database for Active Record
# gem 'sqlite3'
#
gem 'mongoid', '~> 4.0.2'
gem 'bson_ext'
# Use postgresql as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
+3 -17
View File
@@ -1,5 +1,5 @@
GEM
remote: https://ruby.taobao.org/
remote: https://rubygems.org/
specs:
actionmailer (4.2.3)
actionpack (= 4.2.3)
@@ -39,8 +39,6 @@ GEM
arel (6.0.2)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
bson (3.1.2)
bson_ext (1.5.1)
builder (3.2.2)
byebug (5.0.0)
columnize (= 0.9.0)
@@ -52,7 +50,6 @@ GEM
execjs
coffee-script-source (1.9.1.1)
columnize (0.9.0)
connection_pool (2.2.0)
debug_inspector (0.0.2)
erubis (2.7.0)
execjs (2.5.2)
@@ -74,20 +71,10 @@ GEM
mime-types (2.6.1)
mini_portile (0.6.2)
minitest (5.7.0)
mongoid (4.0.2)
activemodel (~> 4.0)
moped (~> 2.0.0)
origin (~> 2.1)
tzinfo (>= 0.3.37)
moped (2.0.6)
bson (~> 3.0)
connection_pool (~> 2.0)
optionable (~> 0.2.0)
multi_json (1.11.2)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
optionable (0.2.0)
origin (2.1.1)
pg (0.18.2)
rack (1.6.4)
rack-test (0.6.3)
rack (>= 1.0)
@@ -154,12 +141,11 @@ PLATFORMS
ruby
DEPENDENCIES
bson_ext
byebug
coffee-rails (~> 4.1.0)
jbuilder (~> 2.0)
jquery-rails
mongoid (~> 4.0.2)
pg
rails (= 4.2.3)
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
+2 -14
View File
@@ -1,18 +1,6 @@
require File.expand_path('../boot', __FILE__)
# require 'rails/all'
require "action_controller/railtie"
require "action_mailer/railtie"
# require "active_resource/railtie" # Comment this line for Rails 4.0+
require "rails/test_unit/railtie"
require "bson"
require "moped"
Moped::BSON = BSON
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
@@ -33,6 +21,6 @@ module LibrX
# config.i18n.default_locale = :de
# Do not swallow errors in after_commit/after_rollback callbacks.
# config.active_record.raise_in_transactional_callbacks = true
config.active_record.raise_in_transactional_callbacks = true
end
end
+85
View File
@@ -0,0 +1,85 @@
# PostgreSQL. Versions 8.2 and up are supported.
#
# Install the pg driver:
# gem install pg
# On OS X with Homebrew:
# gem install pg -- --with-pg-config=/usr/local/bin/pg_config
# On OS X with MacPorts:
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
# On Windows:
# gem install pg
# Choose the win32 build.
# Install PostgreSQL and put its /bin directory on your path.
#
# Configure Using Gemfile
# gem 'pg'
#
default: &default
adapter: postgresql
encoding: unicode
# For details on connection pooling, see rails configuration guide
# http://guides.rubyonrails.org/configuring.html#database-pooling
pool: 5
development:
<<: *default
database: LibrX_development
# The specified database role being used to connect to postgres.
# To create additional roles in postgres see `$ createuser --help`.
# When left blank, postgres will use the default role. This is
# the same name as the operating system user that initialized the database.
#username: LibrX
# The password associated with the postgres role (username).
#password:
# Connect on a TCP socket. Omitted by default since the client uses a
# domain socket that doesn't need configuration. Windows does not have
# domain sockets, so uncomment these lines.
#host: localhost
# The TCP port the server listens on. Defaults to 5432.
# If your server runs on a different port number, change accordingly.
#port: 5432
# Schema search path. The server defaults to $user,public
#schema_search_path: myapp,sharedapp,public
# Minimum log levels, in increasing order:
# debug5, debug4, debug3, debug2, debug1,
# log, notice, warning, error, fatal, and panic
# Defaults to warning.
#min_messages: notice
# 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:
<<: *default
database: LibrX_test
# As with config/secrets.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
# ever seen by anyone, they now have access to your database.
#
# Instead, provide the password as a unix environment variable when you boot
# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
# for a full rundown on how to provide these environment variables in a
# production deployment.
#
# On Heroku and other platform providers, you may have a full connection URL
# available as an environment variable. For example:
#
# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
#
# You can use this database configuration with:
#
# production:
# url: <%= ENV['DATABASE_URL'] %>
#
production:
<<: *default
database: LibrX_production
username: LibrX
password: <%= ENV['LIBRX_DATABASE_PASSWORD'] %>
+1 -1
View File
@@ -20,7 +20,7 @@ Rails.application.configure do
config.active_support.deprecation = :log
# Raise an error on page load if there are pending migrations.
# config.active_record.migration_error = :page_load
config.active_record.migration_error = :page_load
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
+2 -2
View File
@@ -11,10 +11,10 @@
# if you're sharing your code publicly.
development:
secret_key_base: cfe697da7b107061ee88db1c34ce27733c72ca6c1d8b55bc85c553984ad3d429b08f34ab22a2886ae7fdb4eae81a454a7348e08219ab886c51773fd54e60938b
secret_key_base: 3cdddef29e0c14a8effb2353cf02b4ff0ae115992e44367078221b41c0ee94b24001b673ccd1c1df85173eab8c4b1dd9b246bece9a9bae7b486ca489b6fb538a
test:
secret_key_base: b7ce8141cea97b2a683fcda7d429274b3f316ff87b507cc629957d611098598cf432cabed64396fe588311dbcd01a767b03ec586b39ee81a952f9985ac5ae431
secret_key_base: a81364a125879696daabe23a23ebdb1577e03275cc83d80e9e3c109c57a34a16002c33ba7ecebc6f005b8ca80aae7515207da53dc45594561caa353804c7b5ea
# Do not keep production secrets in the repository,
# instead read values from the environment.
+19
View File
@@ -0,0 +1,19 @@
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 0) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
end