Skip to content

Commit

Permalink
remove postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
hooopo committed Oct 26, 2019
1 parent d41bd5e commit aa59ae1
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 481 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ gem 'omniauth-oauth2', require: false
gem 'omniauth-google-oauth2'

gem 'oj'
gem 'pg'
gem 'mini_sql', github: 'hooopo/mini_sql'
gem 'pry-rails', require: false
gem 'r2', '~> 0.2.5', require: false
Expand Down
2 changes: 0 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ GEM
parallel
parser (2.6.3.0)
ast (~> 2.4.0)
pg (1.1.4)
progress (3.5.0)
pry (0.12.2)
coderay (~> 1.1.0)
Expand Down Expand Up @@ -515,7 +514,6 @@ DEPENDENCIES
onebox (= 1.8.92)
openid-redis-store
parallel_tests
pg
pry-nav
pry-rails
puma
Expand Down
6 changes: 0 additions & 6 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,6 @@ def render_rate_limit_error(e)
render_rate_limit_error(e)
end

rescue_from PG::ReadOnlySqlTransaction do |e|
Discourse.received_readonly!
Rails.logger.error("#{e.class} #{e.message}: #{e.backtrace.join("\n")}")
raise Discourse::ReadOnly
end

rescue_from Discourse::NotLoggedIn do |e|
if (request.format && request.format.json?) || request.xhr? || !request.get?
rescue_discourse_actions(:not_logged_in, 403, include_ember: true)
Expand Down
2 changes: 1 addition & 1 deletion app/models/global_setting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def self.reset_s3_cache!
end

def self.database_config
hash = { "adapter" => "postgresql" }
hash = { "adapter" => "mysql2" }

%w{
pool
Expand Down
18 changes: 18 additions & 0 deletions config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@ development:
### - rebake all to posts using: `RAILS_ENV=production bundle exec rake posts:rebake`
- "localhost"

production:
prepared_statements: false
encoding: utf8mb4
socket: /tmp/mysql.sock
adapter: mysql2
database: <%= 'discourse' %>
username: root
min_messages: warning
pool: 5
timeout: 5000
checkout_timeout: <%= ENV['CHECKOUT_TIMEOUT'] || 5 %>
host_names:
### Don't include the port number here. Change the "port" site setting instead, at /admin/site_settings.
### If you change this setting you will need to
### - restart sidekiq if you change this setting
### - rebake all to posts using: `RAILS_ENV=production bundle exec rake posts:rebake`
- "localhost"

# 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.
Expand Down
3 changes: 0 additions & 3 deletions config/initializers/003-sql_builder.rb

This file was deleted.

188 changes: 0 additions & 188 deletions lib/active_record/connection_adapters/postgresql_fallback_adapter.rb

This file was deleted.

2 changes: 1 addition & 1 deletion lib/freedom_patches/active_record_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ActiveRecord::Base
def self.find_or_create_by_safe!(hash)
begin
find_or_create_by!(hash)
rescue PG::UniqueViolation, ActiveRecord::RecordNotUnique, ActiveRecord::RecordInvalid
rescue ActiveRecord::RecordNotUnique, ActiveRecord::RecordInvalid
# try again cause another transaction could have passed by now
find_or_create_by!(hash)
end
Expand Down
10 changes: 0 additions & 10 deletions lib/freedom_patches/postgresql_adapter.rb

This file was deleted.

5 changes: 0 additions & 5 deletions lib/freedom_patches/safe_migrations.rb

This file was deleted.

Loading

0 comments on commit aa59ae1

Please sign in to comment.