activerecord-postgresql-branched 0.2.0 → 0.3.0

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: aaa20a8d3be0ae8ce7427b9b8e826fdcb561274ac39ff7c1b6c4234f06db6a1b
4
- data.tar.gz: f1b437b5cb279a11234e18943d40b33e94897fa2b69cf166453f0a346ceb979e
3
+ metadata.gz: 4824fa89d3e5d0b010916b43302ec81d5190f84ba520a48f9bc8f4b629e30d6f
4
+ data.tar.gz: 423dd436e06d97866c3866a7c139ee932501495c603d7ce2a775211d06fb8190
5
5
  SHA512:
6
- metadata.gz: d1b59c69941701aa595d8def4334bdbe056ebf5b68e91898b3947ea0b2d95cda4fa20e1b1ab5d541c8eb102bcc9fcf182e62a2cdea9e02ffe392eb226d771809
7
- data.tar.gz: 46d5fe4cab69a81ffa6d53a375267848a7c87fa03f6805ec58104f56320310b736ae3cd8e212bf56861105b078e04f4aaa9a6e8035959d89898f0462168eb139
6
+ metadata.gz: 67ff1ed660c4b1c442235624b64b4c5c2b1fed7a632957b3aa64b622a7c1340aa1e3e3f3b03368ec63d508131f4d29f5fca43fe440c277a1c7893e95f1f69c34
7
+ data.tar.gz: b9a96791beaca51e65470d50f0a2bc92991c16f432cc47c437259cbc3ef860171e45b2d0e72de35fdae5c7d10cb4edfacb30795d66f753346cc2435f9223fdd2
data/CHANGELOG.md CHANGED
@@ -1,9 +1,10 @@
1
1
  # Changelog
2
2
 
3
- ## 0.2.0
3
+ ## 0.3.0
4
4
 
5
5
  - Remove primary branch concept — every branch gets its own schema equally
6
6
  - Add shadow interception for `add_foreign_key`, `remove_foreign_key`, `add_check_constraint`, `remove_check_constraint`, `validate_foreign_key`, `validate_check_constraint`
7
+ - Add `db:branch:console` rake task — opens psql with the branch `search_path`
7
8
  - Simplify branch resolution to `PGBRANCH` env var with git fallback
8
9
  - Remove `branch_override` config option and `BRANCH` env var
9
10
  - `db:branch:prune` accepts `KEEP=branch1,branch2` for explicit control
data/README.md CHANGED
@@ -122,8 +122,13 @@ rails db:branch:discard # drop current branch schema (or BRANCH=name
122
122
  rails db:branch:list # list all branch schemas and their sizes
123
123
  rails db:branch:diff # show tables in the current branch schema
124
124
  rails db:branch:prune # drop stale schemas (KEEP=main,feature/x or auto-detect from git)
125
+ rails db:branch:console # open psql with the branch search_path
125
126
  ```
126
127
 
128
+ ### psql
129
+
130
+ `psql` connects directly to PostgreSQL and knows nothing about branch schemas. Use `db:branch:console` instead — it launches psql with `search_path` set to your branch schema, so you see exactly what your Rails app sees.
131
+
127
132
  ## Configuration
128
133
 
129
134
  The adapter needs one thing: a branch name. Resolution order:
@@ -62,6 +62,22 @@ module ActiveRecord
62
62
  tables.each { |t| puts " #{t}" }
63
63
  end
64
64
  end
65
+
66
+ desc "Open psql with the branch search_path"
67
+ task console: :load_config do
68
+ manager = branch_manager
69
+ config = ActiveRecord::Base.connection_db_config.configuration_hash
70
+
71
+ env = { "PGOPTIONS" => "-c search_path=#{manager.branch_schema},public" }
72
+ args = ["psql"]
73
+ args.push("-h", config[:host].to_s) if config[:host]
74
+ args.push("-p", config[:port].to_s) if config[:port]
75
+ args.push("-U", config[:username].to_s) if config[:username]
76
+ args.push(config[:database].to_s)
77
+
78
+ puts "Connecting to #{config[:database]} as #{manager.branch_schema}..."
79
+ exec(env, *args)
80
+ end
65
81
  end
66
82
  end
67
83
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-postgresql-branched
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carl Dawson