Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
rpbaltazar committed Jan 3, 2020
2 parents e3cc79b + 700c548 commit ddc8351
Show file tree
Hide file tree
Showing 11 changed files with 137 additions and 62 deletions.
31 changes: 23 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
sudo: required
os: linux

language: ruby
services:
- docker
rvm:
- jruby-9.1.15.0
- jruby-9.1.17.0
- 2.1.9
- 2.2.9
- 2.3.6
- 2.4.3
- 2.5.0
- 2.6.2
- ruby-head
gemfile:
- gemfiles/rails_4_2.gemfile
- gemfiles/rails_5_0.gemfile
- gemfiles/rails_5_1.gemfile
- gemfiles/rails_5_2.gemfile
- gemfiles/rails_6_0.gemfile
- gemfiles/rails_master.gemfile
bundler_args: --without local
before_install:
- sudo /etc/init.d/mysql stop
- sudo /etc/init.d/postgresql stop
- docker-compose up -d
- gem install bundler -v '> 1.5.0'
- gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
- gem uninstall bundler -v '>= 2' -x || true
- gem install bundler -v '< 2'
env:
RUBY_GC_MALLOC_LIMIT: 90000000
RUBY_GC_HEAP_FREE_SLOTS: 200000
matrix:
jobs:
allow_failures:
- rvm: ruby-head
- gemfile: gemfiles/rails_master.gemfile
- rvm: jruby-9.1.15.0
- rvm: jruby-9.1.17.0
gemfile: gemfiles/rails_5_0.gemfile
exclude:
- rvm: 2.1.9
Expand All @@ -38,13 +43,23 @@ matrix:
gemfile: gemfiles/rails_5_1.gemfile
- rvm: 2.1.9
gemfile: gemfiles/rails_5_2.gemfile
- rvm: 2.1.9
gemfile: gemfiles/rails_6_0.gemfile
- rvm: 2.1.9
gemfile: gemfiles/rails_master.gemfile
- rvm: jruby-9.1.15.0
- rvm: 2.2.9
gemfile: gemfiles/rails_6_0.gemfile
- rvm: 2.3.6
gemfile: gemfiles/rails_6_0.gemfile
- rvm: 2.4.3
gemfile: gemfiles/rails_6_0.gemfile
- rvm: jruby-9.1.17.0
gemfile: gemfiles/rails_5_1.gemfile
- rvm: jruby-9.1.15.0
- rvm: jruby-9.1.17.0
gemfile: gemfiles/rails_5_2.gemfile
- rvm: jruby-9.1.15.0
- rvm: jruby-9.1.17.0
gemfile: gemfiles/rails_6_0.gemfile
- rvm: jruby-9.1.17.0
gemfile: gemfiles/rails_master.gemfile
fast_finish: true
cache: bundler
29 changes: 23 additions & 6 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,34 @@ end
appraise "rails-5-2" do
gem "rails", "~> 5.2.0"
platforms :jruby do
gem 'activerecord-jdbc-adapter', '~> 51.0'
gem 'activerecord-jdbcpostgresql-adapter', '~> 51.0'
gem 'activerecord-jdbcmysql-adapter', '~> 51.0'
gem 'activerecord-jdbc-adapter', '~> 52.0'
gem 'activerecord-jdbcpostgresql-adapter', '~> 52.0'
gem 'activerecord-jdbcmysql-adapter', '~> 52.0'
end
end


appraise "rails-6-0" do
gem "rails", "~> 6.0.0.rc1"
platforms :ruby do
gem 'sqlite3', '~> 1.4'
end
platforms :jruby do
gem 'activerecord-jdbc-adapter', '~> 60.0.rc1'
gem 'activerecord-jdbcpostgresql-adapter', '~> 60.0.rc1'
gem 'activerecord-jdbcmysql-adapter', '~> 60.0.rc1'
end
end


appraise "rails-master" do
gem "rails", git: 'https://github.com/rails/rails.git'
platforms :ruby do
gem 'sqlite3', '~> 1.4'
end
platforms :jruby do
gem 'activerecord-jdbc-adapter', '~> 51.0'
gem 'activerecord-jdbcpostgresql-adapter', '~> 51.0'
gem 'activerecord-jdbcmysql-adapter', '~> 51.0'
gem 'activerecord-jdbc-adapter', '~> 52.0'
gem 'activerecord-jdbcpostgresql-adapter', '~> 52.0'
gem 'activerecord-jdbcmysql-adapter', '~> 52.0'
end
end
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ source 'http://rubygems.org'

gemspec

gem 'rails', '>= 3.1.2'
gem 'rails', '>= 3.1.2'

group :local do
gem 'pry'
Expand Down
7 changes: 7 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# 2.3.0
* January 3, 2020

## Added
- Basic support for rails 6
- Released different gem name, with same API as apartment

# 2.2.1
* June 19, 2019

Expand Down
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,21 @@ Apartment provides tools to help you deal with multiple tenants in your Rails
application. If you need to have certain data sequestered based on account or company,
but still allow some data to exist in a common tenant, Apartment can help.

## HELP!
## Apartment drop in replacement gem

In order to help drive the direction of development and clean up the codebase, we'd like to take a poll
on how people are currently using Apartment. If you can take 5 seconds (1 question) to answer
this poll, we'd greatly appreciated it.
After having reached out via github issues and email directly, no replies ever
came. Since we wanted to upgrade our application to Rails 6 we decided to fork
and start some development to support Rails 6. Because we don't have access
to the apartment gem itself, the solution was to release it under a different
name but providing the exact same API as it was before.

[View Poll](http://www.poll-maker.com/poll391552x4Bfb41a9-15)
## Help wanted

## Excessive Memory Issues on ActiveRecord 4.x

> If you're noticing ever growing memory issues (ie growing with each tenant you add)
> when using Apartment, that's because there's [an issue](https://github.com/rails/rails/issues/19578)
> with how ActiveRecord maps Postgresql data types into AR data types.
> This has been patched and will be released for AR 4.2.2. It's apparently hard
> to backport to 4.1 unfortunately.
> If you're noticing high memory usage from ActiveRecord with Apartment please upgrade.
```ruby
gem 'rails', '4.2.1', github: 'influitive/rails', tag: 'v4.2.1.memfix'
```
We were never involved with the development of Apartment gem in the first place
and this project started out of our own needs. We will be more than happy
to collaborate to maintain the gem alive and supporting the latest versions
of ruby and rails, but your help is appreciated. Either by reporting bugs you
may find or proposing improvements to the gem itself. Feel free to reach out.

## Installation

Expand All @@ -38,7 +33,7 @@ gem 'rails', '4.2.1', github: 'influitive/rails', tag: 'v4.2.1.memfix'
Add the following to your Gemfile:

```ruby
gem 'apartment'
gem 'ros-apartment'
```

Then generate your `Apartment` config file using
Expand Down Expand Up @@ -484,7 +479,7 @@ Note that you can disable the default migrating of all tenants with `db:migrate`

Apartment supports parallelizing migrations into multiple threads when
you have a large number of tenants. By default, parallel migrations is
turned off. You can enable this by setting `parallel_migration_threads` to
turned off. You can enable this by setting `parallel_migration_threads` to
the number of threads you want to use in your initializer.

Keep in mind that because migrations are going to access the database,
Expand Down Expand Up @@ -531,7 +526,12 @@ end

## Background workers

See [apartment-sidekiq](https://github.com/influitive/apartment-sidekiq) or [apartment-activejob](https://github.com/influitive/apartment-activejob).
Both these gems have been forked as a side consequence of having a new gem name.
You can use them exactly as you were using before. They are, just like this one
a drop-in replacement.

See [apartment-sidekiq](https://github.com/rails-on-services/apartment-sidekiq)
or [apartment-activejob](https://github.com/rails-on-services/apartment-activejob).

## Callbacks

Expand Down
10 changes: 9 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,18 @@ def activerecord_below_5_2?
ActiveRecord.version.release < Gem::Version.new('5.2.0')
end

def activerecord_below_6_0?
ActiveRecord.version.release < Gem::Version.new('6.0.0')
end

def migrate
if activerecord_below_5_2?
ActiveRecord::Migrator.migrate('spec/dummy/db/migrate')
else
elsif activerecord_below_6_0?
ActiveRecord::MigrationContext.new('spec/dummy/db/migrate').migrate
else
# TODO: Figure out if there is any other possibility that can/should be
# passed here as the second argument for the migration context
ActiveRecord::MigrationContext.new('spec/dummy/db/migrate', ActiveRecord::SchemaMigration).migrate
end
end
40 changes: 21 additions & 19 deletions apartment.gemspec
Original file line number Diff line number Diff line change
@@ -1,45 +1,47 @@
# -*- encoding: utf-8 -*-
$: << File.expand_path("../lib", __FILE__)
require "apartment/version"
# frozen_string_literal: true

$LOAD_PATH << File.expand_path('lib', __dir__)
require 'apartment/version'

Gem::Specification.new do |s|
s.name = %q{apartment}
s.name = 'ros-apartment'
s.version = Apartment::VERSION

s.authors = ["Ryan Brunner", "Brad Robertson"]
s.summary = %q{A Ruby gem for managing database multitenancy}
s.description = %q{Apartment allows Rack applications to deal with database multitenancy through ActiveRecord}
s.email = ["ryan@influitive.com", "brad@influitive.com"]
s.authors = ['Ryan Brunner', 'Brad Robertson', 'Rui Baltazar']
s.summary = 'A Ruby gem for managing database multitenancy. Apartment Gem drop in replacement'
s.description = 'Apartment allows Rack applications to deal with database multitenancy through ActiveRecord'
s.email = ['ryan@influitive.com', 'brad@influitive.com', 'rui.p.baltazar@gmail.com']
s.files = `git ls-files`.split($/)
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
s.executables = s.files.grep(%r{^bin/}).map { |f| File.basename(f) }
s.test_files = s.files.grep(%r{^(test|spec|features)/})
s.require_paths = ["lib"]
s.require_paths = ['lib']

s.homepage = %q{https://github.com/influitive/apartment}
s.licenses = ["MIT"]
s.homepage = 'https://github.com/rails-on-services/apartment'
s.licenses = ['MIT']

# must be >= 3.1.2 due to bug in prepared_statements
s.add_dependency 'activerecord', '>= 3.1.2', '< 6.0'
s.add_dependency 'rack', '>= 1.3.6'
s.add_dependency 'public_suffix', '>= 2'
s.add_dependency 'activerecord', '>= 3.1.2', '< 6.1'
s.add_dependency 'parallel', '>= 0.7.1'
s.add_dependency 'public_suffix', '>= 2'
s.add_dependency 'rack', '>= 1.3.6'

s.add_development_dependency 'appraisal'
s.add_development_dependency 'bundler', '>= 1.3', '< 2.0'
s.add_development_dependency 'capybara', '~> 2.0'
s.add_development_dependency 'rake', '~> 0.9'
s.add_development_dependency 'rspec', '~> 3.4'
s.add_development_dependency 'rspec-rails', '~> 3.4'
s.add_development_dependency 'capybara', '~> 2.0'

if defined?(JRUBY_VERSION)
s.add_development_dependency 'activerecord-jdbc-adapter'
s.add_development_dependency 'activerecord-jdbcpostgresql-adapter'
s.add_development_dependency 'activerecord-jdbcmysql-adapter'
s.add_development_dependency 'jdbc-postgres'
s.add_development_dependency 'activerecord-jdbcpostgresql-adapter'
s.add_development_dependency 'jdbc-mysql'
s.add_development_dependency 'jdbc-postgres'
s.add_development_dependency 'jruby-openssl'
else
s.add_development_dependency 'mysql2'
s.add_development_dependency 'pg'
s.add_development_dependency 'sqlite3'
s.add_development_dependency 'sqlite3', '~> 1.3.6'
end
end
6 changes: 3 additions & 3 deletions gemfiles/rails_5_2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ group :local do
end

platforms :jruby do
gem "activerecord-jdbc-adapter", "~> 51.0"
gem "activerecord-jdbcpostgresql-adapter", "~> 51.0"
gem "activerecord-jdbcmysql-adapter", "~> 51.0"
gem "activerecord-jdbc-adapter", "~> 52.0"
gem "activerecord-jdbcpostgresql-adapter", "~> 52.0"
gem "activerecord-jdbcmysql-adapter", "~> 52.0"
end

gemspec path: "../"
22 changes: 22 additions & 0 deletions gemfiles/rails_6_0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This file was generated by Appraisal

source "http://rubygems.org"

gem "rails", "~> 6.0.0.rc1"

group :local do
gem "pry"
gem "guard-rspec", "~> 4.2"
end

platforms :ruby do
gem "sqlite3", "~> 1.4"
end

platforms :jruby do
gem "activerecord-jdbc-adapter", "~> 60.0.rc1"
gem "activerecord-jdbcpostgresql-adapter", "~> 60.0.rc1"
gem "activerecord-jdbcmysql-adapter", "~> 60.0.rc1"
end

gemspec path: "../"
10 changes: 7 additions & 3 deletions gemfiles/rails_master.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ group :local do
gem "guard-rspec", "~> 4.2"
end

platforms :ruby do
gem "sqlite3", "~> 1.4"
end

platforms :jruby do
gem "activerecord-jdbc-adapter", "~> 51.0"
gem "activerecord-jdbcpostgresql-adapter", "~> 51.0"
gem "activerecord-jdbcmysql-adapter", "~> 51.0"
gem "activerecord-jdbc-adapter", "~> 52.0"
gem "activerecord-jdbcpostgresql-adapter", "~> 52.0"
gem "activerecord-jdbcmysql-adapter", "~> 52.0"
end

gemspec path: "../"
2 changes: 1 addition & 1 deletion lib/apartment/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Apartment
VERSION = "2.2.1"
VERSION = "2.3.0"
end

0 comments on commit ddc8351

Please sign in to comment.