db-git 0.1.0__tar.gz → 0.2.0__tar.gz
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.
- db_git-0.2.0/.github/workflows/release.yml +79 -0
- {db_git-0.1.0 → db_git-0.2.0}/.github/workflows/test.yml +29 -28
- {db_git-0.1.0 → db_git-0.2.0}/.pre-commit-config.yaml +1 -1
- {db_git-0.1.0 → db_git-0.2.0}/CHANGELOG.md +9 -2
- {db_git-0.1.0 → db_git-0.2.0}/PKG-INFO +61 -52
- {db_git-0.1.0 → db_git-0.2.0}/README.md +55 -46
- {db_git-0.1.0 → db_git-0.2.0}/noxfile.py +1 -1
- {db_git-0.1.0 → db_git-0.2.0}/pyproject.toml +19 -8
- db_git-0.2.0/src/db_git/__init__.py +3 -0
- {db_git-0.1.0/src/git_db → db_git-0.2.0/src/db_git}/backends/__init__.py +9 -9
- {db_git-0.1.0/src/git_db → db_git-0.2.0/src/db_git}/backends/postgresql/backend.py +10 -10
- {db_git-0.1.0/src/git_db → db_git-0.2.0/src/db_git}/backends/postgresql/branch_db.py +10 -10
- {db_git-0.1.0/src/git_db → db_git-0.2.0/src/db_git}/backends/postgresql/connections.py +4 -4
- {db_git-0.1.0/src/git_db → db_git-0.2.0/src/db_git}/backends/postgresql/pgdump.py +10 -10
- {db_git-0.1.0/src/git_db → db_git-0.2.0/src/db_git}/backends/postgresql/template.py +9 -9
- {db_git-0.1.0/src/git_db → db_git-0.2.0/src/db_git}/cli/__init__.py +1 -1
- db_git-0.2.0/src/db_git/cli/_common.py +41 -0
- {db_git-0.1.0/src/git_db → db_git-0.2.0/src/db_git}/cli/_console.py +1 -1
- {db_git-0.1.0/src/git_db → db_git-0.2.0/src/db_git}/cli/_prompts.py +1 -1
- {db_git-0.1.0/src/git_db → db_git-0.2.0/src/db_git}/cli/branch.py +13 -13
- {db_git-0.1.0/src/git_db → db_git-0.2.0/src/db_git}/cli/hook.py +13 -13
- {db_git-0.1.0/src/git_db → db_git-0.2.0/src/db_git}/cli/init.py +16 -16
- {db_git-0.1.0/src/git_db → db_git-0.2.0/src/db_git}/cli/inspect.py +71 -21
- {db_git-0.1.0/src/git_db → db_git-0.2.0/src/db_git}/cli/snapshot.py +11 -11
- {db_git-0.1.0/src/git_db → db_git-0.2.0/src/db_git}/config.py +34 -30
- {db_git-0.1.0/src/git_db → db_git-0.2.0/src/db_git}/db.py +12 -1
- {db_git-0.1.0/src/git_db → db_git-0.2.0/src/db_git}/errors.py +9 -9
- {db_git-0.1.0/src/git_db → db_git-0.2.0/src/db_git}/git.py +20 -20
- db_git-0.2.0/src/db_git/hook_script.py +49 -0
- {db_git-0.1.0/src/git_db → db_git-0.2.0/src/db_git}/state.py +11 -11
- {db_git-0.1.0/src/git_db → db_git-0.2.0/src/db_git}/storage.py +7 -7
- {db_git-0.1.0 → db_git-0.2.0}/tests/_pg_helpers.py +11 -11
- {db_git-0.1.0 → db_git-0.2.0}/tests/conftest.py +4 -4
- {db_git-0.1.0 → db_git-0.2.0}/tests/e2e/_helpers.py +3 -3
- {db_git-0.1.0 → db_git-0.2.0}/tests/e2e/test_per_branch_pgdump_workflow.py +68 -37
- {db_git-0.1.0 → db_git-0.2.0}/tests/e2e/test_per_branch_template_workflow.py +69 -38
- {db_git-0.1.0 → db_git-0.2.0}/tests/e2e/test_shared_pgdump_workflow.py +73 -65
- {db_git-0.1.0 → db_git-0.2.0}/tests/e2e/test_shared_template_workflow.py +78 -70
- {db_git-0.1.0 → db_git-0.2.0}/tests/integration/conftest.py +11 -11
- {db_git-0.1.0 → db_git-0.2.0}/tests/integration/test_branch_db.py +6 -6
- {db_git-0.1.0 → db_git-0.2.0}/tests/integration/test_connections.py +9 -9
- {db_git-0.1.0 → db_git-0.2.0}/tests/integration/test_pgdump_strategy.py +11 -11
- {db_git-0.1.0 → db_git-0.2.0}/tests/integration/test_template_strategy.py +14 -14
- {db_git-0.1.0 → db_git-0.2.0}/tests/unit/test_cli.py +93 -28
- {db_git-0.1.0 → db_git-0.2.0}/tests/unit/test_config.py +32 -32
- db_git-0.2.0/tests/unit/test_db.py +41 -0
- {db_git-0.1.0 → db_git-0.2.0}/tests/unit/test_git.py +4 -4
- {db_git-0.1.0 → db_git-0.2.0}/tests/unit/test_state.py +7 -7
- {db_git-0.1.0 → db_git-0.2.0}/tests/unit/test_storage.py +4 -4
- {db_git-0.1.0 → db_git-0.2.0}/uv.lock +41 -41
- db_git-0.1.0/.claude/settings.local.json +0 -26
- db_git-0.1.0/src/git_db/__init__.py +0 -1
- db_git-0.1.0/src/git_db/cli/_common.py +0 -41
- db_git-0.1.0/src/git_db/hook_script.py +0 -49
- db_git-0.1.0/tests/unit/test_db.py +0 -23
- {db_git-0.1.0 → db_git-0.2.0}/.github/dependabot.yml +0 -0
- {db_git-0.1.0 → db_git-0.2.0}/.gitignore +0 -0
- {db_git-0.1.0 → db_git-0.2.0}/LICENSE +0 -0
- {db_git-0.1.0/src/git_db → db_git-0.2.0/src/db_git}/backends/postgresql/__init__.py +0 -0
- {db_git-0.1.0/src/git_db → db_git-0.2.0/src/db_git}/cli/_format.py +0 -0
- {db_git-0.1.0 → db_git-0.2.0}/tests/__init__.py +0 -0
- {db_git-0.1.0 → db_git-0.2.0}/tests/e2e/__init__.py +0 -0
- {db_git-0.1.0 → db_git-0.2.0}/tests/e2e/conftest.py +0 -0
- {db_git-0.1.0 → db_git-0.2.0}/tests/integration/__init__.py +0 -0
- {db_git-0.1.0 → db_git-0.2.0}/tests/unit/__init__.py +0 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
name: release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_run:
|
|
5
|
+
workflows: [test]
|
|
6
|
+
branches: [main]
|
|
7
|
+
types: [completed]
|
|
8
|
+
|
|
9
|
+
concurrency:
|
|
10
|
+
group: ${{ github.workflow }}-${{ github.event.workflow_run.head_branch }}
|
|
11
|
+
cancel-in-progress: false
|
|
12
|
+
|
|
13
|
+
permissions:
|
|
14
|
+
contents: read
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
release:
|
|
18
|
+
name: semantic release
|
|
19
|
+
runs-on: ubuntu-latest
|
|
20
|
+
if: github.event.workflow_run.conclusion == 'success'
|
|
21
|
+
permissions:
|
|
22
|
+
contents: write
|
|
23
|
+
id-token: write
|
|
24
|
+
outputs:
|
|
25
|
+
released: ${{ steps.release.outputs.released || 'false' }}
|
|
26
|
+
steps:
|
|
27
|
+
- name: Checkout release branch
|
|
28
|
+
uses: actions/checkout@v6
|
|
29
|
+
with:
|
|
30
|
+
ref: ${{ github.event.workflow_run.head_branch }}
|
|
31
|
+
fetch-depth: 0
|
|
32
|
+
|
|
33
|
+
- name: Reset to tested commit
|
|
34
|
+
run: git reset --hard "${{ github.event.workflow_run.head_sha }}"
|
|
35
|
+
|
|
36
|
+
- name: Semantic version release
|
|
37
|
+
id: release
|
|
38
|
+
uses: python-semantic-release/python-semantic-release@v10.5.3
|
|
39
|
+
with:
|
|
40
|
+
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
41
|
+
git_committer_name: "github-actions"
|
|
42
|
+
git_committer_email: "actions@users.noreply.github.com"
|
|
43
|
+
|
|
44
|
+
- name: Upload distributions to GitHub Release
|
|
45
|
+
if: steps.release.outputs.released == 'true'
|
|
46
|
+
uses: python-semantic-release/publish-action@v10.5.3
|
|
47
|
+
with:
|
|
48
|
+
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
49
|
+
tag: ${{ steps.release.outputs.tag }}
|
|
50
|
+
|
|
51
|
+
- name: Upload distributions artifact
|
|
52
|
+
if: steps.release.outputs.released == 'true'
|
|
53
|
+
uses: actions/upload-artifact@v7
|
|
54
|
+
with:
|
|
55
|
+
name: distribution-artifacts
|
|
56
|
+
path: dist
|
|
57
|
+
if-no-files-found: error
|
|
58
|
+
|
|
59
|
+
publish:
|
|
60
|
+
name: publish to PyPI
|
|
61
|
+
runs-on: ubuntu-latest
|
|
62
|
+
needs: release
|
|
63
|
+
if: needs.release.outputs.released == 'true'
|
|
64
|
+
permissions:
|
|
65
|
+
actions: read
|
|
66
|
+
contents: read
|
|
67
|
+
id-token: write
|
|
68
|
+
steps:
|
|
69
|
+
- name: Download distributions artifact
|
|
70
|
+
uses: actions/download-artifact@v8
|
|
71
|
+
with:
|
|
72
|
+
name: distribution-artifacts
|
|
73
|
+
path: dist
|
|
74
|
+
|
|
75
|
+
- name: Publish package distributions to PyPI
|
|
76
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
77
|
+
with:
|
|
78
|
+
packages-dir: dist
|
|
79
|
+
print-hash: true
|
|
@@ -10,6 +10,34 @@ concurrency:
|
|
|
10
10
|
cancel-in-progress: true
|
|
11
11
|
|
|
12
12
|
jobs:
|
|
13
|
+
lint:
|
|
14
|
+
name: ruff
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v6
|
|
18
|
+
- uses: astral-sh/setup-uv@v7
|
|
19
|
+
with:
|
|
20
|
+
enable-cache: true
|
|
21
|
+
- uses: actions/setup-python@v6
|
|
22
|
+
with:
|
|
23
|
+
python-version: "3.12"
|
|
24
|
+
- run: pipx install nox
|
|
25
|
+
- run: nox -s lint
|
|
26
|
+
|
|
27
|
+
types:
|
|
28
|
+
name: mypy
|
|
29
|
+
runs-on: ubuntu-latest
|
|
30
|
+
steps:
|
|
31
|
+
- uses: actions/checkout@v6
|
|
32
|
+
- uses: astral-sh/setup-uv@v7
|
|
33
|
+
with:
|
|
34
|
+
enable-cache: true
|
|
35
|
+
- uses: actions/setup-python@v6
|
|
36
|
+
with:
|
|
37
|
+
python-version: "3.12"
|
|
38
|
+
- run: pipx install nox
|
|
39
|
+
- run: nox -s types
|
|
40
|
+
|
|
13
41
|
unit:
|
|
14
42
|
name: unit (${{ matrix.python }})
|
|
15
43
|
runs-on: ubuntu-latest
|
|
@@ -30,6 +58,7 @@ jobs:
|
|
|
30
58
|
integration:
|
|
31
59
|
name: integration (py${{ matrix.python }}, pg${{ matrix.postgres }})
|
|
32
60
|
runs-on: ubuntu-latest
|
|
61
|
+
needs: [lint, types, unit]
|
|
33
62
|
strategy:
|
|
34
63
|
fail-fast: false
|
|
35
64
|
matrix:
|
|
@@ -51,31 +80,3 @@ jobs:
|
|
|
51
80
|
sudo apt-get install -y postgresql-client-${{ matrix.postgres }}
|
|
52
81
|
- run: pipx install nox
|
|
53
82
|
- run: nox -s "integration-${{ matrix.python }}(pg_image='postgres:${{ matrix.postgres }}')"
|
|
54
|
-
|
|
55
|
-
types:
|
|
56
|
-
name: mypy
|
|
57
|
-
runs-on: ubuntu-latest
|
|
58
|
-
steps:
|
|
59
|
-
- uses: actions/checkout@v6
|
|
60
|
-
- uses: astral-sh/setup-uv@v7
|
|
61
|
-
with:
|
|
62
|
-
enable-cache: true
|
|
63
|
-
- uses: actions/setup-python@v6
|
|
64
|
-
with:
|
|
65
|
-
python-version: "3.12"
|
|
66
|
-
- run: pipx install nox
|
|
67
|
-
- run: nox -s types
|
|
68
|
-
|
|
69
|
-
lint:
|
|
70
|
-
name: ruff
|
|
71
|
-
runs-on: ubuntu-latest
|
|
72
|
-
steps:
|
|
73
|
-
- uses: actions/checkout@v6
|
|
74
|
-
- uses: astral-sh/setup-uv@v7
|
|
75
|
-
with:
|
|
76
|
-
enable-cache: true
|
|
77
|
-
- uses: actions/setup-python@v6
|
|
78
|
-
with:
|
|
79
|
-
python-version: "3.12"
|
|
80
|
-
- run: pipx install nox
|
|
81
|
-
- run: nox -s lint
|
|
@@ -9,7 +9,7 @@ and this project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.ht
|
|
|
9
9
|
|
|
10
10
|
### Added
|
|
11
11
|
|
|
12
|
-
- Initial `git
|
|
12
|
+
- Initial `db-git` command-line interface.
|
|
13
13
|
- Git `post-checkout` hook installation, removal, enable, disable, and dispatch
|
|
14
14
|
support.
|
|
15
15
|
- Shared database mode for saving and restoring branch-specific snapshots.
|
|
@@ -18,8 +18,15 @@ and this project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.ht
|
|
|
18
18
|
- Active connection handling with `terminate` and `fail` policies.
|
|
19
19
|
- Manual commands for `save`, `restore`, `create`, `reset`, `list`, `status`,
|
|
20
20
|
and `prune`.
|
|
21
|
-
- Snapshot metadata and local state storage under `.git/git
|
|
21
|
+
- Snapshot metadata and local state storage under `.git/db-git/`.
|
|
22
22
|
- Unit, integration, and end-to-end tests for CLI, storage, git hooks,
|
|
23
23
|
PostgreSQL strategies, and branch database workflows.
|
|
24
24
|
- Nox sessions, Ruff linting/format checks, mypy type checking, pre-commit
|
|
25
25
|
hooks, Dependabot, and GitHub Actions CI.
|
|
26
|
+
|
|
27
|
+
## [0.1.1] - 2026-06-01
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
|
|
31
|
+
- Renamed project, CLI, package imports, configuration files, environment
|
|
32
|
+
variables, hook metadata, and local state paths to `db-git`.
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: db-git
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Keep your database in sync with your git branches.
|
|
5
|
-
Project-URL: Homepage, https://github.com/earthcomfy/git
|
|
6
|
-
Project-URL: Repository, https://github.com/earthcomfy/git
|
|
7
|
-
Project-URL: Issues, https://github.com/earthcomfy/git
|
|
8
|
-
Project-URL: Changelog, https://github.com/earthcomfy/git
|
|
5
|
+
Project-URL: Homepage, https://github.com/earthcomfy/db-git
|
|
6
|
+
Project-URL: Repository, https://github.com/earthcomfy/db-git
|
|
7
|
+
Project-URL: Issues, https://github.com/earthcomfy/db-git/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/earthcomfy/db-git/blob/main/CHANGELOG.md
|
|
9
9
|
Author: Hana Belay
|
|
10
10
|
License-Expression: MIT
|
|
11
11
|
License-File: LICENSE
|
|
12
12
|
Keywords: branching,cli,database,developer-tools,git,migrations,postgresql,snapshot
|
|
13
|
-
Classifier: Development Status ::
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
14
|
Classifier: Environment :: Console
|
|
15
15
|
Classifier: Intended Audience :: Developers
|
|
16
16
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -29,15 +29,15 @@ Requires-Dist: tomlkit>=0.14.0
|
|
|
29
29
|
Requires-Dist: typer>=0.24.1
|
|
30
30
|
Description-Content-Type: text/markdown
|
|
31
31
|
|
|
32
|
-
# git
|
|
32
|
+
# db-git
|
|
33
33
|
|
|
34
|
-
[](https://github.com/earthcomfy/db-git/actions/workflows/test.yml)
|
|
35
|
+
[](https://pypi.org/project/db-git/)
|
|
36
36
|
[](LICENSE)
|
|
37
37
|
|
|
38
38
|
Keep your database in sync with your git branches.
|
|
39
39
|
|
|
40
|
-
`git
|
|
40
|
+
`db-git` is a developer tool for projects where database state follows code
|
|
41
41
|
changes: schema migrations, seed data, experimental feature work, and branch
|
|
42
42
|
switching during reviews. It installs a git `post-checkout` hook and keeps your
|
|
43
43
|
local database aligned with the branch you are working on.
|
|
@@ -57,19 +57,19 @@ local database aligned with the branch you are working on.
|
|
|
57
57
|
- `pgdump`: portable snapshots using `pg_dump` and `pg_restore`
|
|
58
58
|
- Manual `save`, `restore`, `create`, `reset`, `list`, `status`, and `prune`
|
|
59
59
|
commands
|
|
60
|
-
- Safe hook behavior: checkout is never blocked by git
|
|
61
|
-
- Rich terminal output and local state stored under `.git/git
|
|
60
|
+
- Safe hook behavior: checkout is never blocked by db-git failures
|
|
61
|
+
- Rich terminal output and local state stored under `.git/db-git/`
|
|
62
62
|
|
|
63
63
|
## Quick Start
|
|
64
64
|
|
|
65
65
|
```bash
|
|
66
|
-
uv tool install git
|
|
66
|
+
uv tool install db-git # or pip install db-git
|
|
67
67
|
```
|
|
68
68
|
|
|
69
69
|
Run this from inside a git repository:
|
|
70
70
|
|
|
71
71
|
```bash
|
|
72
|
-
git
|
|
72
|
+
db-git init --database-url postgresql://postgres:postgres@localhost:5432/myapp
|
|
73
73
|
```
|
|
74
74
|
|
|
75
75
|
Interactive init will ask:
|
|
@@ -85,10 +85,10 @@ After setup, switch branches normally:
|
|
|
85
85
|
git checkout feature/auth
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
-
In `shared` mode, git
|
|
88
|
+
In `shared` mode, db-git saves the previous branch database and restores the
|
|
89
89
|
new branch snapshot if one exists.
|
|
90
90
|
|
|
91
|
-
In `per-branch` mode, git
|
|
91
|
+
In `per-branch` mode, db-git creates or selects a database named from the
|
|
92
92
|
current branch, for example:
|
|
93
93
|
|
|
94
94
|
```text
|
|
@@ -99,6 +99,14 @@ Because the database name changes per branch, your application server also
|
|
|
99
99
|
needs to connect to the branch database. For example, when working on
|
|
100
100
|
`feature/auth`, point your app's `DATABASE_URL` at `myapp__feature__auth`.
|
|
101
101
|
|
|
102
|
+
`db-git url` prints the full connection URL for the current branch, so you can
|
|
103
|
+
hand it straight to your app or client:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
export DATABASE_URL=$(db-git url)
|
|
107
|
+
psql "$(db-git url)"
|
|
108
|
+
```
|
|
109
|
+
|
|
102
110
|
## Choosing a Mode
|
|
103
111
|
|
|
104
112
|
### Shared Mode
|
|
@@ -109,7 +117,7 @@ Use this when:
|
|
|
109
117
|
|
|
110
118
|
- You want one familiar local database name
|
|
111
119
|
- You want branch-specific snapshots
|
|
112
|
-
- You are comfortable with git
|
|
120
|
+
- You are comfortable with db-git dropping and restoring that local database
|
|
113
121
|
during branch switches
|
|
114
122
|
|
|
115
123
|
### Per-Branch Mode
|
|
@@ -148,13 +156,13 @@ not available. It requires PostgreSQL client tools to be installed locally.
|
|
|
148
156
|
### Initialize
|
|
149
157
|
|
|
150
158
|
```bash
|
|
151
|
-
git
|
|
159
|
+
db-git init --database-url postgresql://user:password@localhost:5432/myapp
|
|
152
160
|
```
|
|
153
161
|
|
|
154
162
|
Useful options:
|
|
155
163
|
|
|
156
164
|
```bash
|
|
157
|
-
git
|
|
165
|
+
db-git init \
|
|
158
166
|
--database-url postgresql://user:password@localhost:5432/myapp \
|
|
159
167
|
--mode per-branch \
|
|
160
168
|
--strategy template \
|
|
@@ -164,14 +172,15 @@ git-db init \
|
|
|
164
172
|
Skip hook installation:
|
|
165
173
|
|
|
166
174
|
```bash
|
|
167
|
-
git
|
|
175
|
+
db-git init --database-url postgresql://localhost/myapp --no-hook
|
|
168
176
|
```
|
|
169
177
|
|
|
170
178
|
### Inspect State
|
|
171
179
|
|
|
172
180
|
```bash
|
|
173
|
-
git
|
|
174
|
-
git
|
|
181
|
+
db-git status
|
|
182
|
+
db-git list
|
|
183
|
+
db-git url
|
|
175
184
|
```
|
|
176
185
|
|
|
177
186
|
### Shared Mode Commands
|
|
@@ -179,20 +188,20 @@ git-db list
|
|
|
179
188
|
Save the current branch database:
|
|
180
189
|
|
|
181
190
|
```bash
|
|
182
|
-
git
|
|
191
|
+
db-git save
|
|
183
192
|
```
|
|
184
193
|
|
|
185
194
|
Restore the current branch database:
|
|
186
195
|
|
|
187
196
|
```bash
|
|
188
|
-
git
|
|
197
|
+
db-git restore
|
|
189
198
|
```
|
|
190
199
|
|
|
191
200
|
Save or restore a specific branch:
|
|
192
201
|
|
|
193
202
|
```bash
|
|
194
|
-
git
|
|
195
|
-
git
|
|
203
|
+
db-git save main
|
|
204
|
+
db-git restore feature/auth
|
|
196
205
|
```
|
|
197
206
|
|
|
198
207
|
### Per-Branch Commands
|
|
@@ -200,13 +209,13 @@ git-db restore feature/auth
|
|
|
200
209
|
Create a branch database before checking out the branch:
|
|
201
210
|
|
|
202
211
|
```bash
|
|
203
|
-
git
|
|
212
|
+
db-git create feature/auth
|
|
204
213
|
```
|
|
205
214
|
|
|
206
215
|
Drop and recreate a branch database from the seed database:
|
|
207
216
|
|
|
208
217
|
```bash
|
|
209
|
-
git
|
|
218
|
+
db-git reset feature/auth
|
|
210
219
|
```
|
|
211
220
|
|
|
212
221
|
The default branch database cannot be reset because it is the seed for other
|
|
@@ -217,13 +226,13 @@ branch databases.
|
|
|
217
226
|
Preview stale snapshots or branch databases:
|
|
218
227
|
|
|
219
228
|
```bash
|
|
220
|
-
git
|
|
229
|
+
db-git prune --dry-run
|
|
221
230
|
```
|
|
222
231
|
|
|
223
232
|
Remove stale snapshots or branch databases:
|
|
224
233
|
|
|
225
234
|
```bash
|
|
226
|
-
git
|
|
235
|
+
db-git prune --yes
|
|
227
236
|
```
|
|
228
237
|
|
|
229
238
|
### Hook Management
|
|
@@ -231,31 +240,31 @@ git-db prune --yes
|
|
|
231
240
|
Install or reinstall the checkout hook:
|
|
232
241
|
|
|
233
242
|
```bash
|
|
234
|
-
git
|
|
243
|
+
db-git hook install
|
|
235
244
|
```
|
|
236
245
|
|
|
237
246
|
Remove the checkout hook:
|
|
238
247
|
|
|
239
248
|
```bash
|
|
240
|
-
git
|
|
249
|
+
db-git hook remove
|
|
241
250
|
```
|
|
242
251
|
|
|
243
|
-
Temporarily disable git
|
|
252
|
+
Temporarily disable db-git without removing the hook:
|
|
244
253
|
|
|
245
254
|
```bash
|
|
246
|
-
git
|
|
247
|
-
git
|
|
255
|
+
db-git disable
|
|
256
|
+
db-git enable
|
|
248
257
|
```
|
|
249
258
|
|
|
250
259
|
You can also skip hook behavior for a single checkout:
|
|
251
260
|
|
|
252
261
|
```bash
|
|
253
|
-
|
|
262
|
+
DB_GIT_SKIP=1 git checkout other-branch
|
|
254
263
|
```
|
|
255
264
|
|
|
256
265
|
## Configuration
|
|
257
266
|
|
|
258
|
-
`git
|
|
267
|
+
`db-git init` writes `.db-git.toml` at the repository root.
|
|
259
268
|
|
|
260
269
|
Example:
|
|
261
270
|
|
|
@@ -276,14 +285,14 @@ Supported configuration keys:
|
|
|
276
285
|
| `default_branch` | Seed branch for per-branch mode | `main` |
|
|
277
286
|
| `strategy` | `template` or `pgdump` | required |
|
|
278
287
|
| `on_active_connections` | `terminate` or `fail` | `terminate` |
|
|
279
|
-
| `snapshot_dir` | Shared-mode snapshot metadata/dump directory | `.git/git
|
|
288
|
+
| `snapshot_dir` | Shared-mode snapshot metadata/dump directory | `.git/db-git/snapshots` |
|
|
280
289
|
| `max_snapshots` | Snapshot count kept by prune logic | `20` |
|
|
281
290
|
| `force_terminate_timeout_ms` | Active connection termination timeout | `5000` |
|
|
282
291
|
|
|
283
292
|
Configuration precedence:
|
|
284
293
|
|
|
285
294
|
1. Built-in defaults
|
|
286
|
-
2. `.git
|
|
295
|
+
2. `.db-git.toml`
|
|
287
296
|
3. Environment variables
|
|
288
297
|
4. CLI options
|
|
289
298
|
|
|
@@ -291,16 +300,16 @@ Environment variables:
|
|
|
291
300
|
|
|
292
301
|
```bash
|
|
293
302
|
DATABASE_URL
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
303
|
+
DB_GIT_DATABASE_URL
|
|
304
|
+
DB_GIT_MODE
|
|
305
|
+
DB_GIT_STRATEGY
|
|
306
|
+
DB_GIT_ON_ACTIVE_CONNECTIONS
|
|
307
|
+
DB_GIT_SNAPSHOT_DIR
|
|
308
|
+
DB_GIT_MAX_SNAPSHOTS
|
|
309
|
+
DB_GIT_FORCE_TERMINATE_TIMEOUT_MS
|
|
301
310
|
```
|
|
302
311
|
|
|
303
|
-
`
|
|
312
|
+
`DB_GIT_DATABASE_URL` takes precedence over `DATABASE_URL`.
|
|
304
313
|
|
|
305
314
|
### Active connections block an operation
|
|
306
315
|
|
|
@@ -316,24 +325,24 @@ on_active_connections = "terminate"
|
|
|
316
325
|
Your PostgreSQL user may need superuser privileges or membership in
|
|
317
326
|
`pg_signal_backend` to terminate sessions owned by other users.
|
|
318
327
|
|
|
319
|
-
### Temporarily skip git
|
|
328
|
+
### Temporarily skip db-git
|
|
320
329
|
|
|
321
330
|
```bash
|
|
322
|
-
git
|
|
331
|
+
db-git disable
|
|
323
332
|
git checkout some-branch
|
|
324
|
-
git
|
|
333
|
+
db-git enable
|
|
325
334
|
```
|
|
326
335
|
|
|
327
336
|
Or for one command:
|
|
328
337
|
|
|
329
338
|
```bash
|
|
330
|
-
|
|
339
|
+
DB_GIT_SKIP=1 git checkout some-branch
|
|
331
340
|
```
|
|
332
341
|
|
|
333
342
|
### Show full tracebacks
|
|
334
343
|
|
|
335
344
|
```bash
|
|
336
|
-
|
|
345
|
+
DB_GIT_DEBUG=1 db-git status
|
|
337
346
|
```
|
|
338
347
|
|
|
339
348
|
## Development
|