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 +4 -4
- data/CHANGELOG.md +2 -1
- data/README.md +5 -0
- data/lib/active_record/connection_adapters/postgresql/branched/railtie.rb +16 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4824fa89d3e5d0b010916b43302ec81d5190f84ba520a48f9bc8f4b629e30d6f
|
|
4
|
+
data.tar.gz: 423dd436e06d97866c3866a7c139ee932501495c603d7ce2a775211d06fb8190
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 67ff1ed660c4b1c442235624b64b4c5c2b1fed7a632957b3aa64b622a7c1340aa1e3e3f3b03368ec63d508131f4d29f5fca43fe440c277a1c7893e95f1f69c34
|
|
7
|
+
data.tar.gz: b9a96791beaca51e65470d50f0a2bc92991c16f432cc47c437259cbc3ef860171e45b2d0e72de35fdae5c7d10cb4edfacb30795d66f753346cc2435f9223fdd2
|
data/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 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
|
|