Skip to content

Commit f9828a0

Browse files
seven1mbensie
andauthored
feat(Rails7): Update for Rails 7 and MySQL 8 (#2)
* Override raw_execute to be compatible with Rails 7+ * Add a changelog and bump version for release * Update Appraisals to run on modern Rails * Depend on ActiveRecord 7 and up * Fix docker-compose config format * Add GitHub workflow for specs * Mark unsafe sql as safe for this spec * Also handle ActiveRecord::DatabaseConnectionError * Fix typos * Test with MySQL 8 * Fix spec for MySQL 8, where auto_increment still goes up * Update badge and words in readme * Combine old and new changelog, update with undocumented versions * Do not retry on ActiveRecord::StatementTimeout errors * lock to ~> 7.0.0 and add a note for the reason --------- Co-authored-by: James Miller <[email protected]>
1 parent e4e4f8a commit f9828a0

17 files changed

+135
-148
lines changed

.github/workflows/specs.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Specs
2+
on:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
branches: [main]
7+
jobs:
8+
run-rspec:
9+
runs-on: ubuntu-22.04
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v2
13+
- name: Setup Ruby and install gems
14+
uses: ruby/setup-ruby@v1
15+
with:
16+
ruby-version: 3.1
17+
bundler-cache: true
18+
- name: Install gems with Appraisal
19+
run: bundle exec appraisal install
20+
- name: Run RSpec
21+
run: bundle exec appraisal rspec

Appraisals

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,3 @@
1-
appraise "activerecord-4.2" do
2-
gem "activerecord", "~> 4.2.0"
3-
gem "mysql2", "< 0.5"
4-
end
5-
6-
appraise "activerecord-5.0" do
7-
gem "activerecord", "~> 5.0.0"
8-
end
9-
10-
appraise "activerecord-5.1" do
11-
gem "activerecord", "~> 5.1.0"
12-
end
13-
14-
appraise "activerecord-5.2" do
15-
gem "activerecord", "~> 5.2.0"
16-
end
17-
18-
appraise "activerecord-6.0" do
19-
gem "activerecord", "~> 6.0.2"
20-
end
21-
22-
appraise "activerecord-master" do
23-
gem "activerecord", git: "https://github.com/rails/rails.git"
1+
appraise "activerecord-7.0" do
2+
gem "activerecord", "~> 7.0.0"
243
end

CHANGELOG.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
## 1.0.0 (unreleased)
2+
3+
- Feature: Add support for Rails 7
4+
- Change: Drop support for older versions
5+
- Chore: Test against MySQL 8
6+
- Fix: Handle ActiveRecord::ConnectionNotEstablished errors too
7+
- Fix: Do not retry on ActiveRecord::StatementTimeout errors
8+
9+
## 0.5.0 (Jan 29, 2020)
10+
11+
- Change error message for Rails 6.0
12+
- Load database config from db_config instead
13+
- Add Active Record 6.0 and master to build matrix
14+
15+
## 0.4.2 (Aug 15, 2018)
16+
17+
- Add activerecord-5.2 test
18+
- Add error messages accessor
19+
- Fix mysql2 dependency
20+
- Added "Connection was killed" as an error string to reconnect on.
21+
22+
## 0.4.1 (Aug 8, 2016)
23+
24+
- Support AR 5.0 (RP#5 @ssig33)
25+
- Fix test (use docker-compose)
26+
27+
## 0.4.0 (Mar 22, 2016)
28+
29+
- Remove `retryable_transaction`
30+
- Disable support AR 3.x 4.0
31+
32+
## 0.3.3 (Jan 18, 2014)
33+
34+
- use BigDecimal for sleep
35+
- add handling error ('The MySQL server is running with the --read-only...')
36+
37+
## 0.3.1 (Jan 9, 2014)
38+
39+
- Retry mode is added
40+
41+
## 0.3.0 (Jan 9, 2014)
42+
43+
- Retry is disabled by default
44+
- Read-only mode is added
45+
46+
## 0.2.0 (Jan 4, 2014)
47+
48+
- Retry transaction is supported
49+
50+
## 0.1.0 (Oct 11, 2013)
51+
52+
- activerecord-mysql-reconnect is released

ChangeLog

Lines changed: 0 additions & 31 deletions
This file was deleted.

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# activerecord-mysql-reconnect
22

3-
It is the library to reconnect automatically when ActiveRecord is disconnected from MySQL.
3+
Reconnect automatically when ActiveRecord is disconnected from MySQL. Supports Rails 7+ and MySQL 8.
44

5-
[![Gem Version](https://badge.fury.io/rb/activerecord-mysql-reconnect.svg)](http://badge.fury.io/rb/activerecord-mysql-reconnect)
6-
[![Build Status](https://travis-ci.org/winebarrel/activerecord-mysql-reconnect.svg?branch=master)](https://travis-ci.org/winebarrel/activerecord-mysql-reconnect)
5+
[![Specs](https://github.com/planningcenter/activerecord-mysql-reconnect/actions/workflows/specs.yml/badge.svg)](https://github.com/planningcenter/activerecord-mysql-reconnect/actions/workflows/specs.yml)
76

87
## Installation
98

activerecord-mysql-reconnect.gemspec

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ Gem::Specification.new do |spec|
1818
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
1919
spec.require_paths = ['lib']
2020

21-
# '~> 4.2.6'
22-
spec.add_dependency 'activerecord'
21+
# We are going to stop using this in Rails 7.1 and beyond in favor of newly
22+
# added reconnect / retry functionality. The Platform team will provide
23+
# instructions for replacing this gem once 7.1 is released.
24+
spec.add_dependency 'activerecord', '~> 7.0.0'
2325
spec.add_dependency 'mysql2'
2426
spec.add_development_dependency 'bundler'
2527
spec.add_development_dependency 'rake'

docker-compose.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
mysql_for_ar_mysql_reconn:
2-
image: "mysql:5.6"
3-
ports:
4-
- "14407:3306"
5-
environment:
6-
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
1+
services:
2+
mysql:
3+
image: "mysql:8"
4+
ports:
5+
- "14407:3306"
6+
environment:
7+
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"

gemfiles/activerecord_4.2.gemfile

Lines changed: 0 additions & 8 deletions
This file was deleted.

gemfiles/activerecord_5.0.gemfile

Lines changed: 0 additions & 7 deletions
This file was deleted.

gemfiles/activerecord_5.1.gemfile

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)