dotenv_rails_db_tasks_fix 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.env.development +1 -1
- data/.env.test +1 -1
- data/README.md +2 -2
- data/Rakefile +13 -2
- data/config/database.yml +7 -0
- data/config/schema.rb +0 -0
- data/lib/dotenv_rails_db_tasks_fix/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7cdbc7371e683a8fffbeb782c080b6e4a6eeb5b004c0ea9ecd20f6bf0ff33db9
|
4
|
+
data.tar.gz: eff0da22841e866e4c63dbb5d1c400a992e78c854c73dbcc7a6c61c35209e0e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: adf98752b518ccf7d585951a420b7a2268cc8d6cd42c8b4253bae0ca138765185351042b6192ac6baa2300c8cfc6c2e2f69cdd9ca8cd33541b1d4c7680ff7e5b
|
7
|
+
data.tar.gz: f14069f3af974b9b23234310b782a7e38980287c146ebe1004dc7e3ac8019186466e42f45a78f9ec1d900bee306e0c5d62d576bf7db4a4f50ad34e5fb7fc2fce
|
data/.env.development
CHANGED
@@ -1 +1 @@
|
|
1
|
-
DB_DATABASE=
|
1
|
+
DB_DATABASE=file:mem_db_development?mode=memory
|
data/.env.test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
DB_DATABASE=
|
1
|
+
DB_DATABASE=file:mem_db_test?mode=memory
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
#### Fix for the issue when ActiveRecord `rake db:*` tasks are magically executed in both developement and test environments, but environment variables loaded via `dotenv` are not picking up the change.
|
4
4
|
|
5
|
-
*You are viewing the README of version [v0.2.
|
5
|
+
*You are viewing the README of version [v0.2.1](https://github.com/thisismydesign/dotenv_rails_db_tasks_fix/releases/tag/v0.2.1). You can find other releases [here](https://github.com/thisismydesign/dotenv_rails_db_tasks_fix/releases).*
|
6
6
|
|
7
7
|
| Branch | Status |
|
8
8
|
| ------ | ------ |
|
@@ -85,7 +85,7 @@ See also [this issue](https://github.com/thisismydesign/dotenv_rails_db_tasks_fi
|
|
85
85
|
- Outside of `development` environment `DotenvRailsDbTasksFix.activate` will `raise` and will _not_ monkey patch
|
86
86
|
- Database config is expected to reside in Rails default `#{DatabaseTasks.root}/config/database.yml` (if you're using Rails `DatabaseTasks.root == Rails.root`)
|
87
87
|
- Requires ActiveRecord >= 5.1.5, ~> 5.1.6 (because there're slight differences in the private API, althoguh following this solution it would be easy to extend support for other versions)
|
88
|
-
- There's some weirdness with `Rails.env` vs `DatabaseTasks.env`. From trial-and-error it seems changing `DatabaseTasks.env` to reflect the current execution env will result in issues (with e.g. `db:setup` and `db:reset`), while changing `Rails.env` is actually required for `db:setup` to work correctly. [This fix](https://github.com/thisismydesign/dotenv_rails_db_tasks_fix/blob/
|
88
|
+
- There's some weirdness with `Rails.env` vs `DatabaseTasks.env`. From trial-and-error it seems changing `DatabaseTasks.env` to reflect the current execution env will result in issues (with e.g. `db:setup` and `db:reset`), while changing `Rails.env` is actually required for `db:setup` to work correctly. [This fix](https://github.com/thisismydesign/dotenv_rails_db_tasks_fix/blob/v0.2.0/lib/dotenv_rails_db_tasks_fix.rb#L25-L29) seems to work for the use cases I tried but it's good to keep this in mind in case any similar issue presents. This might be due to this issue: https://github.com/rails/rails/issues/32910
|
89
89
|
- If you introduce this to a project currently in use a final `db:environment:set` might be needed if prompted
|
90
90
|
|
91
91
|
## Installation
|
data/Rakefile
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require "rspec/core/rake_task"
|
3
|
-
require
|
3
|
+
require "dotenv"
|
4
|
+
require "yaml"
|
5
|
+
require "erb"
|
4
6
|
|
5
7
|
require_relative "lib/dotenv_rails_db_tasks_fix"
|
6
8
|
require_relative "spec/support/active_record_tasks"
|
@@ -12,8 +14,17 @@ task :default => :spec
|
|
12
14
|
RSPEC_ROOT = Pathname.new(File.dirname(__FILE__)).join("spec")
|
13
15
|
environment = ENV["RAILS_ENV"] || "development"
|
14
16
|
project_path = Pathname.new(RSPEC_ROOT).join("example_project")
|
17
|
+
class Seeder; def load_seed; end; end
|
18
|
+
# Root path has to be execution path, see: https://github.com/rails/rails/issues/32910
|
19
|
+
# Config is expected at `#{root}/config/database.yml`
|
20
|
+
# If the issue above is fixed it can be moved to `#{root}/spec/example_project/config/database.yml`
|
21
|
+
root = Pathname.new(".")
|
22
|
+
db_config = root.join("config", "database.yml")
|
23
|
+
db_dir = root.join("config")
|
15
24
|
|
16
25
|
Dotenv.overload(".env", ".env.#{environment}", ".env.local", ".env.#{environment}.local")
|
17
|
-
|
26
|
+
config = YAML::load(ERB.new(File.read(db_config)).result)
|
27
|
+
|
28
|
+
load_active_record_tasks(database_configuration: config, root: root, db_dir: db_dir, seed_loader: Seeder.new)
|
18
29
|
|
19
30
|
DotenvRailsDbTasksFix.activate
|
data/config/database.yml
ADDED
data/config/schema.rb
ADDED
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dotenv_rails_db_tasks_fix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thisismydesign
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -132,6 +132,8 @@ files:
|
|
132
132
|
- Rakefile
|
133
133
|
- bin/console
|
134
134
|
- bin/setup
|
135
|
+
- config/database.yml
|
136
|
+
- config/schema.rb
|
135
137
|
- dotenv_rails_db_tasks_fix.gemspec
|
136
138
|
- lib/dotenv_rails_db_tasks_fix.rb
|
137
139
|
- lib/dotenv_rails_db_tasks_fix/version.rb
|