Skip to content

Commit eaecc39

Browse files
authored
Merge pull request #9 from procore/ys/INFR-1421_support_strong_migrations
Support strong_migrations gem
2 parents 49e7a32 + ef9cbe0 commit eaecc39

File tree

12 files changed

+80
-24
lines changed

12 files changed

+80
-24
lines changed

.circleci/config.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
version: 2
2+
jobs:
3+
build:
4+
# working_directory: ~/appName
5+
docker:
6+
- image: ruby:2.3.3
7+
environment:
8+
PG_HOST: localhost
9+
PG_USER: ubuntu
10+
- image: circleci/postgres:9.5-ram
11+
environment:
12+
POSTGRES_USER: ubuntu
13+
POSTGRES_DB: circle_test
14+
steps:
15+
- checkout
16+
- run:
17+
name: Install Ruby Dependencies
18+
command: bundle install
19+
- run:
20+
name: Install Appraisals Dependencies
21+
command: bundle exec appraisal install
22+
- run:
23+
name: Run Appraisals Tests
24+
environment:
25+
POSTGRES_DB_DATABASE: circle_test
26+
POSTGRES_DB_USERNAME: ubuntu
27+
POSTGRES_DB_PASSWORD:
28+
command: bundle exec appraisal rspec

Appraisals

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ appraise "activerecord-4" do
22
gem "activerecord", "4.2.7.1"
33
end
44

5+
appraise "activerecord-4_with_strong_migrations" do
6+
gem "activerecord", "4.2.7.1"
7+
gem "strong_migrations", "0.2"
8+
end
9+
510
appraise "activerecord-5" do
611
gem "activerecord", "5.0.0.1"
712
end
13+
14+
appraise "activerecord-5_with_strong_migrations" do
15+
gem "activerecord", "5.0.0.1"
16+
gem "strong_migrations", "0.2"
17+
end

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
4+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6+
7+
## [1.2.0]
8+
### Added
9+
- Support for using with the [strong_migrations](https://github.com/ankane/strong_migrations) gem

circle.yml

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

gemfiles/activerecord_4.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ source "https://rubygems.org"
44

55
gem "activerecord", "4.2.7.1"
66

7-
gemspec :path => "../"
7+
gemspec path: "../"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# This file was generated by Appraisal
2+
3+
source "https://rubygems.org"
4+
5+
gem "activerecord", "4.2.7.1"
6+
gem "strong_migrations", "0.2"
7+
8+
gemspec path: "../"

gemfiles/activerecord_5.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ source "https://rubygems.org"
44

55
gem "activerecord", "5.0.0.1"
66

7-
gemspec :path => "../"
7+
gemspec path: "../"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# This file was generated by Appraisal
2+
3+
source "https://rubygems.org"
4+
5+
gem "activerecord", "5.0.0.1"
6+
gem "strong_migrations", "0.2"
7+
8+
gemspec path: "../"

lib/migration_lock_timeout/lock_manager.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,22 @@ module LockManager
33

44
def migrate(direction)
55
timeout_disabled = self.class.disable_lock_timeout
6-
time = self.class.lock_timeout_override ||
6+
time = self.class.lock_timeout_override ||
77
MigrationLockTimeout.try(:config).try(:default_timeout)
88
if !timeout_disabled && direction == :up && time && !disable_ddl_transaction
9-
execute "SET LOCAL lock_timeout = '#{time}s'"
9+
safety_assured? do
10+
execute "SET LOCAL lock_timeout = '#{time}s'"
11+
end
1012
end
1113
super
1214
end
15+
16+
def safety_assured?
17+
if defined?(StrongMigrations)
18+
safety_assured { yield }
19+
else
20+
yield
21+
end
22+
end
1323
end
1424
end
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module MigrationLockTimeout
2-
VERSION = "1.1.0"
2+
VERSION = "1.2.0".freeze
33
end

0 commit comments

Comments
 (0)