apartment 0.25.0 → 0.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7511a4af17aae3dc546bb1c76342c5b8301829c6
4
- data.tar.gz: 819a8d11d7cf74fea4d67d9d7c364c92f6bf8aeb
3
+ metadata.gz: 03f280f5d2148e5b660dde41e23369489468087a
4
+ data.tar.gz: ade6d3c1bb87c88bd9d2c5068cd6c569d9c02a46
5
5
  SHA512:
6
- metadata.gz: 67dbe1ad054395e0466e785b9c3d81d17b7ff97147a2e04f76b1af951a806045bd774e6a9cf4c372860389d9b63919cb22d742c6165b1d25bbe60505a1b41d9d
7
- data.tar.gz: 4fd680bc07c8e12f5a88fc143a1a26c09c289b6ae9c3a96296b5d3b48137cfd680132a6aa2b1ac28e3316d9350dae1fe43c9c718b49088cdf1ff18366dfafee6
6
+ metadata.gz: 380c40d97af604ca13f4f2be3cee4acf8f204608ca1591e1108486da41601f64221efb7191982bb0bbcd5ffc6e68dcdf4eb4c3eec0c57984423e2e647967651c
7
+ data.tar.gz: 54ee70f9434af342864877bdebb7f20679593b3c0041bda6c50ea7717cf444fc55de78e126e94f2cdd57379fb315d5b41c14bc5a9a4f0608021cd85318ec2ab1
data/HISTORY.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 0.25.0
2
+ * July 17, 2014
3
+
4
+ - Fixed a few vestiges of Apartment::Database
5
+
1
6
  # 0.25.0
2
7
  * July 3, 2014
3
8
 
data/README.md CHANGED
@@ -253,7 +253,15 @@ schema_search_path: "public,shared_extensions"
253
253
  ...
254
254
  ```
255
255
 
256
- This would be for a config with `default_schema` set to `public` and `persistent_schemas` set to `['shared_extensions']`. **Note**: This only works on Heroku with [Rails 4.1+](https://devcenter.heroku.com/changelog-items/427). For older Rails versions Heroku regenerates a completely different `database.yml` for each deploy and your predefined `schema_search_path` will be deleted. ActiveRecord's `schema_search_path` will be the default `\"$user\",public`.
256
+ This would be for a config with `default_schema` set to `public` and `persistent_schemas` set to `['shared_extensions']`. **Note**: This only works on Heroku with [Rails 4.1+](https://devcenter.heroku.com/changelog-items/427). For apps that use older Rails versions hosted on Heroku, the only way to properly setup is to start with a fresh PostgreSQL instance:
257
+
258
+ 1. Append `?schema_search_path=public,hstore` to your `DATABASE_URL` environment variable, by this you don't have to revise the `database.yml` file (which is impossible since Heroku regenerates a completely different and immutable `database.yml` of its own on each deploy)
259
+ 2. Run `heroku pg:psql` from your command line
260
+ 3. And then `DROP EXTENSION hstore;` (**Note:** This will drop all columns that use `hstore` type, so proceed with caution; only do this with a fresh PostgreSQL instance)
261
+ 4. Next: `CREATE SCHEMA IF NOT EXISTS hstore;`
262
+ 5. Finally: `CREATE EXTENSION IF NOT EXISTS hstore SCHEMA hstore;` and hit enter (`\q` to exit)
263
+
264
+ To double check, login to the console of your Heroku app and see if `Apartment.connection.default_search_path` is `public,hstore`
257
265
 
258
266
  #### 3. Ensure the schema is in the apartment config
259
267
  ```ruby
@@ -148,8 +148,6 @@ module Apartment
148
148
  # @return {String} raw SQL contaning only postgres schema dump
149
149
  #
150
150
  def pg_dump_schema
151
- dbname = ActiveRecord::Base.connection_config[:database]
152
- default_schema = Apartment.default_schema
153
151
 
154
152
  # Skip excluded tables? :/
155
153
  # excluded_tables =
@@ -167,7 +165,7 @@ module Apartment
167
165
  # @return {String} raw SQL contaning inserts with data from schema_migrations
168
166
  #
169
167
  def pg_dump_schema_migrations_data
170
- `pg_dump -a --inserts -t schema_migrations -n #{Apartment.default_schema} bithub_development`
168
+ `pg_dump -a --inserts -t schema_migrations -n #{default_schema} #{dbname}`
171
169
  end
172
170
 
173
171
  # Remove "SET search_path ..." line from SQL dump and prepend search_path set to current tenant
@@ -198,6 +196,18 @@ module Apartment
198
196
  end
199
197
  end
200
198
 
199
+ # Convenience method for current database name
200
+ #
201
+ def dbname
202
+ ActiveRecord::Base.connection_config[:database]
203
+ end
204
+
205
+ # Convenience method for the default schema
206
+ #
207
+ def default_schema
208
+ Apartment.default_schema
209
+ end
210
+
201
211
  end
202
212
 
203
213
 
@@ -7,7 +7,7 @@ module Apartment
7
7
 
8
8
  # Migrate to latest
9
9
  def migrate(database)
10
- Database.process(database) do
10
+ Tenant.process(database) do
11
11
  version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
12
12
 
13
13
  ActiveRecord::Migrator.migrate(ActiveRecord::Migrator.migrations_paths, version) do |migration|
@@ -18,14 +18,14 @@ module Apartment
18
18
 
19
19
  # Migrate up/down to a specific version
20
20
  def run(direction, database, version)
21
- Database.process(database) do
21
+ Tenant.process(database) do
22
22
  ActiveRecord::Migrator.run(direction, ActiveRecord::Migrator.migrations_paths, version)
23
23
  end
24
24
  end
25
25
 
26
26
  # rollback latest migration `step` number of times
27
27
  def rollback(database, step = 1)
28
- Database.process(database) do
28
+ Tenant.process(database) do
29
29
  ActiveRecord::Migrator.rollback(ActiveRecord::Migrator.migrations_paths, step)
30
30
  end
31
31
  end
@@ -14,8 +14,8 @@ module Apartment
14
14
  end
15
15
 
16
16
  def call(env)
17
- Database.init
17
+ Tenant.init
18
18
  @app.call(env)
19
19
  end
20
20
  end
21
- end
21
+ end
@@ -1,3 +1,3 @@
1
1
  module Apartment
2
- VERSION = "0.25.0"
2
+ VERSION = "0.25.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apartment
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.25.0
4
+ version: 0.25.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Brunner
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-07-03 00:00:00.000000000 Z
12
+ date: 2014-07-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord