sqldef-rails 0.1.0 → 0.1.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
  SHA256:
3
- metadata.gz: bebf6ded67228c38e91276d345c575bf01c586173af711c9f8104755c3bb11fd
4
- data.tar.gz: bae5639ea7f527cd19fec4087ee541ddb73f171000a55e4c77a5c04cf29f9330
3
+ metadata.gz: da03c8c4850ca52ac66618b69afd3c546dfdd8e60a7c96a5d3bb95138d2b4d26
4
+ data.tar.gz: 8ba2d8ebab8bdb16a0e4c10b388d86177f9320f909edb17d47d09333d5bdc83f
5
5
  SHA512:
6
- metadata.gz: 9df4dc3d271833f9cb786e2ea6743160310f3f4a9e0d9d467e87ea879d1d5cf7b2cf2863a6fd594880f0ca4a8941ab3eb3073022de3495b0738077d310c6e405
7
- data.tar.gz: a9e17526b928590d6883cb2e6c17ba809b0f57a28268ab635cd37b6b7afaabdb2a941672bef6a104421367fd29e245bb82abbf89bea1b26470704edea61c6a6c
6
+ metadata.gz: aacc8b25e4316708e86a319aaa20ca83e81c78f53d244e41fa13b90e5f924b7d0c07d23c67b7dee48a9cf664c4f1d66abcfb89d3e6500a4938e0170cb866ac03
7
+ data.tar.gz: 29abdebd2754214f94bbef3c10479c56f53b79d7f0f7b3f05a66f8cae2ed849a6245f74e3263bb4fc862a915605e7fbeba3eb5c533793d4e99ea1c411f91ae70
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # v0.1.1
2
+
3
+ * Initial support of `DATABASE_URL`
4
+
5
+ # v0.1.0
6
+
7
+ * Initial release
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # sqldef-rails
2
2
 
3
- Run [sqldef](https://github.com/k0kubun/sqldef) with config/database.yml.
3
+ Run [sqldef](https://github.com/k0kubun/sqldef) on Rails.
4
4
 
5
5
  ## Installation
6
6
 
@@ -9,6 +9,47 @@ gem 'sqldef-rails'
9
9
  ```
10
10
 
11
11
  ## Usage
12
+ ### Configuration
13
+
14
+ Just configure `config/database.yml` normally.
15
+
16
+ ```yml
17
+ default: &default
18
+ adapter: postgresql
19
+ username: postgres
20
+ password:
21
+ host: 127.0.0.1
22
+
23
+ development:
24
+ <<: *default
25
+ database: sqldef_development
26
+
27
+ test:
28
+ <<: *default
29
+ database: sqldef_test
30
+ ```
31
+
32
+ ### Export
33
+
34
+ Dump the current schema to `db/schema.sql`.
35
+
36
+ ```bash
37
+ bundle exec rake db:schema:dump
38
+ ```
39
+
40
+ You may use `bin/rails` instead of `bundle exec rake` too.
41
+
42
+ ### Dry Run
43
+
44
+ You can show DDLs to be executed to match `db/schema.sql`.
45
+
46
+ ```bash
47
+ bundle exec rake db:migrate:status
48
+ ```
49
+
50
+ ### Aplly
51
+
52
+ You can run DDLs to match `db/schema.sql`.
12
53
 
13
54
  ```bash
14
55
  bundle exec rake db:migrate
@@ -9,7 +9,7 @@ namespace :sqldef do
9
9
 
10
10
  desc 'Export the database'
11
11
  task export: [:environment] do
12
- database = Rails.application.config_for(:database)
12
+ database = Sqldef::Rails.database_config
13
13
  Sqldef.export(
14
14
  host: database.fetch(:host),
15
15
  port: database[:port],
@@ -23,7 +23,7 @@ namespace :sqldef do
23
23
 
24
24
  desc 'Dry-run the database'
25
25
  task 'dry-run': [:environment] do
26
- database = Rails.application.config_for(:database)
26
+ database = Sqldef::Rails.database_config
27
27
  Sqldef.dry_run(
28
28
  host: database.fetch(:host),
29
29
  port: database[:port],
@@ -37,7 +37,7 @@ namespace :sqldef do
37
37
 
38
38
  desc 'Apply the database'
39
39
  task apply: [:environment] do
40
- database = Rails.application.config_for(:database)
40
+ database = Sqldef::Rails.database_config
41
41
  Sqldef.apply(
42
42
  host: database.fetch(:host),
43
43
  port: database[:port],
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sqldef
4
4
  module Rails
5
- VERSION = '0.1.0'
5
+ VERSION = '0.1.1'
6
6
  end
7
7
  end
data/lib/sqldef/rails.rb CHANGED
@@ -2,3 +2,17 @@
2
2
  require 'sqldef'
3
3
  require 'sqldef/rails/version'
4
4
  require 'sqldef/rails/railtie'
5
+
6
+ module Sqldef
7
+ module Rails
8
+ def self.database_config
9
+ database = ::Rails.application.config_for(:database)
10
+ if ENV.key?('DATABASE_URL')
11
+ database = database.merge(
12
+ ActiveRecord::DatabaseConfigurations::ConnectionUrlResolver.new(ENV['DATABASE_URL']).to_hash
13
+ )
14
+ end
15
+ database
16
+ end
17
+ end
18
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sqldef-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-13 00:00:00.000000000 Z
11
+ date: 2022-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sqldef
@@ -33,6 +33,7 @@ extra_rdoc_files: []
33
33
  files:
34
34
  - ".github/workflows/main.yml"
35
35
  - ".gitignore"
36
+ - CHANGELOG.md
36
37
  - Gemfile
37
38
  - LICENSE.txt
38
39
  - README.md
@@ -66,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
67
  - !ruby/object:Gem::Version
67
68
  version: '0'
68
69
  requirements: []
69
- rubygems_version: 3.2.3
70
+ rubygems_version: 3.3.7
70
71
  signing_key:
71
72
  specification_version: 4
72
73
  summary: Idempotent MySQL/PostgreSQL schema management by SQL