apartment 0.25.0 → 0.25.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY.md +5 -0
- data/README.md +9 -1
- data/lib/apartment/adapters/postgresql_adapter.rb +13 -3
- data/lib/apartment/migrator.rb +3 -3
- data/lib/apartment/reloader.rb +2 -2
- data/lib/apartment/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03f280f5d2148e5b660dde41e23369489468087a
|
4
|
+
data.tar.gz: ade6d3c1bb87c88bd9d2c5068cd6c569d9c02a46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 380c40d97af604ca13f4f2be3cee4acf8f204608ca1591e1108486da41601f64221efb7191982bb0bbcd5ffc6e68dcdf4eb4c3eec0c57984423e2e647967651c
|
7
|
+
data.tar.gz: 54ee70f9434af342864877bdebb7f20679593b3c0041bda6c50ea7717cf444fc55de78e126e94f2cdd57379fb315d5b41c14bc5a9a4f0608021cd85318ec2ab1
|
data/HISTORY.md
CHANGED
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
|
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 #{
|
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
|
|
data/lib/apartment/migrator.rb
CHANGED
@@ -7,7 +7,7 @@ module Apartment
|
|
7
7
|
|
8
8
|
# Migrate to latest
|
9
9
|
def migrate(database)
|
10
|
-
|
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
|
-
|
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
|
-
|
28
|
+
Tenant.process(database) do
|
29
29
|
ActiveRecord::Migrator.rollback(ActiveRecord::Migrator.migrations_paths, step)
|
30
30
|
end
|
31
31
|
end
|
data/lib/apartment/reloader.rb
CHANGED
data/lib/apartment/version.rb
CHANGED
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.
|
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-
|
12
|
+
date: 2014-07-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|