db-git 0.2.0__tar.gz → 0.3.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.
Files changed (157) hide show
  1. db_git-0.3.0/.github/workflows/docs.yml +61 -0
  2. {db_git-0.2.0 → db_git-0.3.0}/.github/workflows/release.yml +1 -1
  3. {db_git-0.2.0 → db_git-0.3.0}/.github/workflows/test.yml +32 -8
  4. {db_git-0.2.0 → db_git-0.3.0}/.gitignore +3 -0
  5. {db_git-0.2.0 → db_git-0.3.0}/.pre-commit-config.yaml +1 -1
  6. db_git-0.3.0/CHANGELOG.md +98 -0
  7. db_git-0.3.0/PKG-INFO +116 -0
  8. db_git-0.3.0/README.md +82 -0
  9. db_git-0.3.0/docs/concepts/modes.md +26 -0
  10. db_git-0.3.0/docs/contributing/development.md +67 -0
  11. db_git-0.3.0/docs/contributing/documentation.md +55 -0
  12. db_git-0.3.0/docs/databases/mysql.md +114 -0
  13. db_git-0.3.0/docs/databases/postgresql.md +63 -0
  14. db_git-0.3.0/docs/databases/sqlite.md +64 -0
  15. db_git-0.3.0/docs/getting-started/installation.md +48 -0
  16. db_git-0.3.0/docs/getting-started/quickstart.md +58 -0
  17. db_git-0.3.0/docs/guides/applications.md +24 -0
  18. db_git-0.3.0/docs/guides/checkpoints.md +60 -0
  19. db_git-0.3.0/docs/guides/recovery.md +63 -0
  20. db_git-0.3.0/docs/guides/upgrading.md +17 -0
  21. db_git-0.3.0/docs/guides/worktrees.md +64 -0
  22. db_git-0.3.0/docs/index.md +51 -0
  23. db_git-0.3.0/docs/reference/commands.md +155 -0
  24. db_git-0.3.0/docs/reference/configuration.md +65 -0
  25. db_git-0.3.0/docs/troubleshooting.md +73 -0
  26. db_git-0.3.0/mkdocs.yml +87 -0
  27. {db_git-0.2.0 → db_git-0.3.0}/noxfile.py +26 -2
  28. {db_git-0.2.0 → db_git-0.3.0}/pyproject.toml +6 -2
  29. db_git-0.3.0/requirements-docs.txt +3 -0
  30. db_git-0.3.0/scripts/ci/Dockerfile +23 -0
  31. db_git-0.3.0/scripts/ci/local.py +141 -0
  32. {db_git-0.2.0 → db_git-0.3.0}/src/db_git/backends/__init__.py +30 -1
  33. db_git-0.3.0/src/db_git/backends/mysql/__init__.py +1 -0
  34. db_git-0.3.0/src/db_git/backends/mysql/backend.py +86 -0
  35. db_git-0.3.0/src/db_git/backends/mysql/branch_db.py +172 -0
  36. db_git-0.3.0/src/db_git/backends/mysql/connections.py +179 -0
  37. db_git-0.3.0/src/db_git/backends/mysql/doctor.py +116 -0
  38. db_git-0.3.0/src/db_git/backends/mysql/dump.py +228 -0
  39. db_git-0.3.0/src/db_git/backends/mysql/objects.py +515 -0
  40. db_git-0.3.0/src/db_git/backends/mysql/operations.py +136 -0
  41. db_git-0.3.0/src/db_git/backends/mysql/permissions.py +113 -0
  42. db_git-0.3.0/src/db_git/backends/mysql/shared.py +211 -0
  43. db_git-0.3.0/src/db_git/backends/mysql/urls.py +78 -0
  44. {db_git-0.2.0 → db_git-0.3.0}/src/db_git/backends/postgresql/backend.py +22 -13
  45. db_git-0.3.0/src/db_git/backends/postgresql/branch_db.py +201 -0
  46. {db_git-0.2.0 → db_git-0.3.0}/src/db_git/backends/postgresql/connections.py +23 -1
  47. db_git-0.3.0/src/db_git/backends/postgresql/operations.py +127 -0
  48. db_git-0.3.0/src/db_git/backends/postgresql/pgdump.py +257 -0
  49. db_git-0.3.0/src/db_git/backends/postgresql/template.py +196 -0
  50. db_git-0.3.0/src/db_git/backends/sqlite/__init__.py +1 -0
  51. db_git-0.3.0/src/db_git/backends/sqlite/backend.py +119 -0
  52. db_git-0.3.0/src/db_git/backends/sqlite/branch_db.py +183 -0
  53. db_git-0.3.0/src/db_git/backends/sqlite/doctor.py +84 -0
  54. db_git-0.3.0/src/db_git/backends/sqlite/files.py +64 -0
  55. db_git-0.3.0/src/db_git/backends/sqlite/operations.py +78 -0
  56. db_git-0.3.0/src/db_git/backends/sqlite/urls.py +34 -0
  57. {db_git-0.2.0 → db_git-0.3.0}/src/db_git/cli/__init__.py +11 -1
  58. {db_git-0.2.0 → db_git-0.3.0}/src/db_git/cli/_common.py +9 -1
  59. {db_git-0.2.0 → db_git-0.3.0}/src/db_git/cli/_console.py +1 -1
  60. {db_git-0.2.0 → db_git-0.3.0}/src/db_git/cli/_format.py +19 -9
  61. db_git-0.3.0/src/db_git/cli/_init_resources.py +39 -0
  62. db_git-0.3.0/src/db_git/cli/_mysql_init.py +84 -0
  63. db_git-0.3.0/src/db_git/cli/_mysql_recover.py +86 -0
  64. {db_git-0.2.0 → db_git-0.3.0}/src/db_git/cli/_prompts.py +12 -6
  65. db_git-0.3.0/src/db_git/cli/_sqlite_init.py +88 -0
  66. db_git-0.3.0/src/db_git/cli/_sqlite_recover.py +70 -0
  67. {db_git-0.2.0 → db_git-0.3.0}/src/db_git/cli/branch.py +51 -21
  68. db_git-0.3.0/src/db_git/cli/doctor.py +32 -0
  69. db_git-0.3.0/src/db_git/cli/history.py +176 -0
  70. {db_git-0.2.0 → db_git-0.3.0}/src/db_git/cli/hook.py +27 -3
  71. {db_git-0.2.0 → db_git-0.3.0}/src/db_git/cli/init.py +70 -17
  72. {db_git-0.2.0 → db_git-0.3.0}/src/db_git/cli/inspect.py +110 -23
  73. db_git-0.3.0/src/db_git/cli/recover.py +166 -0
  74. db_git-0.3.0/src/db_git/cli/run.py +63 -0
  75. {db_git-0.2.0 → db_git-0.3.0}/src/db_git/cli/snapshot.py +37 -2
  76. {db_git-0.2.0 → db_git-0.3.0}/src/db_git/config.py +114 -33
  77. db_git-0.3.0/src/db_git/db.py +83 -0
  78. db_git-0.3.0/src/db_git/doctor.py +634 -0
  79. db_git-0.3.0/src/db_git/files.py +88 -0
  80. {db_git-0.2.0 → db_git-0.3.0}/src/db_git/git.py +120 -38
  81. db_git-0.3.0/src/db_git/history.py +305 -0
  82. {db_git-0.2.0 → db_git-0.3.0}/src/db_git/hook_script.py +11 -9
  83. db_git-0.3.0/src/db_git/recovery.py +206 -0
  84. db_git-0.3.0/src/db_git/repository.py +153 -0
  85. db_git-0.3.0/src/db_git/resources.py +78 -0
  86. db_git-0.3.0/src/db_git/state.py +121 -0
  87. db_git-0.3.0/src/db_git/storage.py +307 -0
  88. db_git-0.3.0/src/db_git/workflow.py +81 -0
  89. db_git-0.3.0/tests/e2e/test_application_workflow.py +195 -0
  90. db_git-0.3.0/tests/e2e/test_history.py +34 -0
  91. {db_git-0.2.0 → db_git-0.3.0}/tests/e2e/test_per_branch_pgdump_workflow.py +8 -5
  92. {db_git-0.2.0 → db_git-0.3.0}/tests/e2e/test_per_branch_template_workflow.py +8 -5
  93. db_git-0.3.0/tests/e2e/test_recovery.py +28 -0
  94. db_git-0.3.0/tests/e2e/test_safety.py +147 -0
  95. {db_git-0.2.0 → db_git-0.3.0}/tests/e2e/test_shared_pgdump_workflow.py +20 -8
  96. {db_git-0.2.0 → db_git-0.3.0}/tests/e2e/test_shared_template_workflow.py +15 -9
  97. db_git-0.3.0/tests/e2e/test_worktrees.py +151 -0
  98. {db_git-0.2.0 → db_git-0.3.0}/tests/integration/test_branch_db.py +8 -7
  99. db_git-0.3.0/tests/integration/test_connection_fidelity.py +108 -0
  100. db_git-0.3.0/tests/integration/test_doctor.py +77 -0
  101. db_git-0.3.0/tests/integration/test_history.py +151 -0
  102. db_git-0.3.0/tests/integration/test_recovery.py +233 -0
  103. db_git-0.3.0/tests/integration/test_snapshot_ownership.py +37 -0
  104. db_git-0.3.0/tests/mysql/conftest.py +88 -0
  105. db_git-0.3.0/tests/mysql/test_extended.py +360 -0
  106. db_git-0.3.0/tests/mysql/test_history.py +120 -0
  107. db_git-0.3.0/tests/mysql/test_init_review.py +41 -0
  108. db_git-0.3.0/tests/mysql/test_mysql.py +412 -0
  109. db_git-0.3.0/tests/mysql/test_object_review.py +84 -0
  110. db_git-0.3.0/tests/mysql/test_workflow_review.py +119 -0
  111. db_git-0.3.0/tests/sqlite/test_sqlite.py +451 -0
  112. db_git-0.3.0/tests/unit/__init__.py +0 -0
  113. db_git-0.3.0/tests/unit/test_checkout_safety.py +90 -0
  114. {db_git-0.2.0 → db_git-0.3.0}/tests/unit/test_cli.py +18 -5
  115. {db_git-0.2.0 → db_git-0.3.0}/tests/unit/test_config.py +41 -0
  116. db_git-0.3.0/tests/unit/test_db.py +238 -0
  117. db_git-0.3.0/tests/unit/test_doctor.py +246 -0
  118. db_git-0.3.0/tests/unit/test_history.py +187 -0
  119. db_git-0.3.0/tests/unit/test_init_resources.py +55 -0
  120. db_git-0.3.0/tests/unit/test_mysql.py +299 -0
  121. db_git-0.3.0/tests/unit/test_mysql_errors.py +23 -0
  122. db_git-0.3.0/tests/unit/test_naming_safety.py +130 -0
  123. db_git-0.3.0/tests/unit/test_recovery.py +246 -0
  124. db_git-0.3.0/tests/unit/test_restore_safety.py +42 -0
  125. {db_git-0.2.0 → db_git-0.3.0}/tests/unit/test_state.py +7 -3
  126. {db_git-0.2.0 → db_git-0.3.0}/tests/unit/test_storage.py +9 -7
  127. db_git-0.3.0/tests/unit/test_workflow.py +203 -0
  128. db_git-0.3.0/tests/unit/test_worktrees.py +197 -0
  129. {db_git-0.2.0 → db_git-0.3.0}/uv.lock +170 -17
  130. db_git-0.2.0/CHANGELOG.md +0 -32
  131. db_git-0.2.0/PKG-INFO +0 -372
  132. db_git-0.2.0/README.md +0 -341
  133. db_git-0.2.0/src/db_git/backends/postgresql/branch_db.py +0 -203
  134. db_git-0.2.0/src/db_git/backends/postgresql/pgdump.py +0 -212
  135. db_git-0.2.0/src/db_git/backends/postgresql/template.py +0 -160
  136. db_git-0.2.0/src/db_git/db.py +0 -28
  137. db_git-0.2.0/src/db_git/state.py +0 -105
  138. db_git-0.2.0/src/db_git/storage.py +0 -203
  139. db_git-0.2.0/tests/unit/test_db.py +0 -41
  140. {db_git-0.2.0 → db_git-0.3.0}/.github/dependabot.yml +0 -0
  141. {db_git-0.2.0 → db_git-0.3.0}/LICENSE +0 -0
  142. {db_git-0.2.0 → db_git-0.3.0}/src/db_git/__init__.py +0 -0
  143. {db_git-0.2.0 → db_git-0.3.0}/src/db_git/backends/postgresql/__init__.py +0 -0
  144. {db_git-0.2.0 → db_git-0.3.0}/src/db_git/errors.py +0 -0
  145. /db_git-0.2.0/tests/__init__.py → /db_git-0.3.0/src/db_git/py.typed +0 -0
  146. {db_git-0.2.0/tests/e2e → db_git-0.3.0/tests}/__init__.py +0 -0
  147. {db_git-0.2.0 → db_git-0.3.0}/tests/_pg_helpers.py +0 -0
  148. {db_git-0.2.0 → db_git-0.3.0}/tests/conftest.py +0 -0
  149. {db_git-0.2.0/tests/integration → db_git-0.3.0/tests/e2e}/__init__.py +0 -0
  150. {db_git-0.2.0 → db_git-0.3.0}/tests/e2e/_helpers.py +0 -0
  151. {db_git-0.2.0 → db_git-0.3.0}/tests/e2e/conftest.py +0 -0
  152. {db_git-0.2.0/tests/unit → db_git-0.3.0/tests/integration}/__init__.py +0 -0
  153. {db_git-0.2.0 → db_git-0.3.0}/tests/integration/conftest.py +0 -0
  154. {db_git-0.2.0 → db_git-0.3.0}/tests/integration/test_connections.py +0 -0
  155. {db_git-0.2.0 → db_git-0.3.0}/tests/integration/test_pgdump_strategy.py +0 -0
  156. {db_git-0.2.0 → db_git-0.3.0}/tests/integration/test_template_strategy.py +0 -0
  157. {db_git-0.2.0 → db_git-0.3.0}/tests/unit/test_git.py +0 -0
@@ -0,0 +1,61 @@
1
+ name: docs
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ paths:
7
+ - docs/**
8
+ - mkdocs.yml
9
+ - requirements-docs.txt
10
+ - .github/workflows/docs.yml
11
+ pull_request:
12
+ paths:
13
+ - docs/**
14
+ - mkdocs.yml
15
+ - requirements-docs.txt
16
+ - .github/workflows/docs.yml
17
+ workflow_dispatch:
18
+
19
+ permissions:
20
+ contents: read
21
+
22
+ concurrency:
23
+ group: docs-${{ github.ref }}
24
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
25
+
26
+ jobs:
27
+ build:
28
+ runs-on: ubuntu-latest
29
+ steps:
30
+ - uses: actions/checkout@v7
31
+ - uses: actions/setup-python@v6
32
+ with:
33
+ python-version: "3.12"
34
+ cache: pip
35
+ cache-dependency-path: requirements-docs.txt
36
+ - name: Install documentation tools
37
+ run: python -m pip install -r requirements-docs.txt
38
+ - name: Validate and build documentation
39
+ run: python -m mkdocs build --strict
40
+ - name: Upload Pages artifact
41
+ if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
42
+ uses: actions/upload-pages-artifact@v3
43
+ with:
44
+ path: site
45
+
46
+ deploy:
47
+ if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
48
+ needs: build
49
+ runs-on: ubuntu-latest
50
+ permissions:
51
+ pages: write
52
+ id-token: write
53
+ environment:
54
+ name: github-pages
55
+ url: ${{ steps.deployment.outputs.page_url }}
56
+ steps:
57
+ - name: Configure GitHub Pages
58
+ uses: actions/configure-pages@v5
59
+ - name: Deploy documentation
60
+ id: deployment
61
+ uses: actions/deploy-pages@v4
@@ -25,7 +25,7 @@ jobs:
25
25
  released: ${{ steps.release.outputs.released || 'false' }}
26
26
  steps:
27
27
  - name: Checkout release branch
28
- uses: actions/checkout@v6
28
+ uses: actions/checkout@v7
29
29
  with:
30
30
  ref: ${{ github.event.workflow_run.head_branch }}
31
31
  fetch-depth: 0
@@ -12,9 +12,9 @@ concurrency:
12
12
  jobs:
13
13
  lint:
14
14
  name: ruff
15
- runs-on: ubuntu-latest
15
+ runs-on: ubuntu-24.04
16
16
  steps:
17
- - uses: actions/checkout@v6
17
+ - uses: actions/checkout@v7
18
18
  - uses: astral-sh/setup-uv@v7
19
19
  with:
20
20
  enable-cache: true
@@ -26,9 +26,9 @@ jobs:
26
26
 
27
27
  types:
28
28
  name: mypy
29
- runs-on: ubuntu-latest
29
+ runs-on: ubuntu-24.04
30
30
  steps:
31
- - uses: actions/checkout@v6
31
+ - uses: actions/checkout@v7
32
32
  - uses: astral-sh/setup-uv@v7
33
33
  with:
34
34
  enable-cache: true
@@ -40,12 +40,12 @@ jobs:
40
40
 
41
41
  unit:
42
42
  name: unit (${{ matrix.python }})
43
- runs-on: ubuntu-latest
43
+ runs-on: ubuntu-24.04
44
44
  strategy:
45
45
  matrix:
46
46
  python: ["3.12", "3.13"]
47
47
  steps:
48
- - uses: actions/checkout@v6
48
+ - uses: actions/checkout@v7
49
49
  - uses: astral-sh/setup-uv@v7
50
50
  with:
51
51
  enable-cache: true
@@ -57,7 +57,7 @@ jobs:
57
57
 
58
58
  integration:
59
59
  name: integration (py${{ matrix.python }}, pg${{ matrix.postgres }})
60
- runs-on: ubuntu-latest
60
+ runs-on: ubuntu-24.04
61
61
  needs: [lint, types, unit]
62
62
  strategy:
63
63
  fail-fast: false
@@ -65,7 +65,7 @@ jobs:
65
65
  python: ["3.12", "3.13"]
66
66
  postgres: ["13", "14", "15", "16", "17"]
67
67
  steps:
68
- - uses: actions/checkout@v6
68
+ - uses: actions/checkout@v7
69
69
  - uses: astral-sh/setup-uv@v7
70
70
  with:
71
71
  enable-cache: true
@@ -80,3 +80,27 @@ jobs:
80
80
  sudo apt-get install -y postgresql-client-${{ matrix.postgres }}
81
81
  - run: pipx install nox
82
82
  - run: nox -s "integration-${{ matrix.python }}(pg_image='postgres:${{ matrix.postgres }}')"
83
+
84
+ mysql:
85
+ name: mysql (py${{ matrix.python }}, mysql${{ matrix.mysql }})
86
+ runs-on: ubuntu-24.04
87
+ needs: [lint, types, unit]
88
+ strategy:
89
+ fail-fast: false
90
+ matrix:
91
+ python: ["3.12", "3.13"]
92
+ mysql: ["8.0", "8.4"]
93
+ steps:
94
+ - uses: actions/checkout@v7
95
+ - uses: astral-sh/setup-uv@v7
96
+ with:
97
+ enable-cache: true
98
+ - uses: actions/setup-python@v6
99
+ with:
100
+ python-version: ${{ matrix.python }}
101
+ - name: Install Oracle MySQL clients
102
+ run: |
103
+ sudo apt-get update
104
+ sudo apt-get install -y mysql-client
105
+ - run: pipx install nox
106
+ - run: nox -s "mysql-${{ matrix.python }}(mysql_image='mysql:${{ matrix.mysql }}')"
@@ -8,3 +8,6 @@ wheels/
8
8
 
9
9
  # Virtual environments
10
10
  .venv
11
+
12
+ # Generated documentation
13
+ /site/
@@ -13,7 +13,7 @@ repos:
13
13
  - id: check-added-large-files
14
14
 
15
15
  - repo: https://github.com/astral-sh/ruff-pre-commit
16
- rev: v0.15.16
16
+ rev: v0.15.18
17
17
  hooks:
18
18
  - id: ruff-check
19
19
  args: [--fix]
@@ -0,0 +1,98 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ <!-- version list -->
9
+
10
+ ## v0.3.0 (2026-09-26)
11
+
12
+ ### Bug Fixes
13
+
14
+ - Align database clients and validate release CI locally
15
+ ([`56600a6`](https://github.com/earthcomfy/db-git/commit/56600a6b43873c44faa619275f2f6f7f2cd424c7))
16
+
17
+ - Prevent unsafe database switches and branch name collisions
18
+ ([`8ae904e`](https://github.com/earthcomfy/db-git/commit/8ae904ed79d7862d5994dcac065be4bde6108fce))
19
+
20
+ ### Build System
21
+
22
+ - **deps**: Bump actions/checkout from 6 to 7 ([#10](https://github.com/earthcomfy/db-git/pull/10),
23
+ [`8a7221a`](https://github.com/earthcomfy/db-git/commit/8a7221ad4b248c15a93349c1d58f7a965e9b65f0))
24
+
25
+ - **deps**: Bump https://github.com/astral-sh/ruff-pre-commit
26
+ ([#11](https://github.com/earthcomfy/db-git/pull/11),
27
+ [`6ff3495`](https://github.com/earthcomfy/db-git/commit/6ff34959ba9655d173f47279ae155d89eb12b41d))
28
+
29
+ ### Chores
30
+
31
+ - Update changelog
32
+ ([`e135315`](https://github.com/earthcomfy/db-git/commit/e13531531c719345ebed747536a8594262b20ead))
33
+
34
+ ### Documentation
35
+
36
+ - Add Material documentation site and Pages workflow
37
+ ([`b3c0b04`](https://github.com/earthcomfy/db-git/commit/b3c0b04f17adc895cd329c705859eb7eddaaa957))
38
+
39
+ ### Features
40
+
41
+ - Add application runner and explicit branch database sources
42
+ ([`eab7f27`](https://github.com/earthcomfy/db-git/commit/eab7f27cf65e58c8fd7ebdad7779a2590c256003))
43
+
44
+ - Add checkpoint history and recoverable retention
45
+ ([`3b495b8`](https://github.com/earthcomfy/db-git/commit/3b495b83cf51d207b20d1b4a6bd11d5ed8735395))
46
+
47
+ - Add doctor diagnostics and preserve PostgreSQL connection options
48
+ ([`6abedd2`](https://github.com/earthcomfy/db-git/commit/6abedd24770a83f3635a5d2751fea3ba70a5d25b))
49
+
50
+ - Add MySQL databases, shared snapshots, and recoverable generations
51
+ ([`124a63a`](https://github.com/earthcomfy/db-git/commit/124a63a8f96742eb8c757aff1b7104976e852cfd))
52
+
53
+ - Add recoverable database and snapshot operations
54
+ ([`51ace0f`](https://github.com/earthcomfy/db-git/commit/51ace0fc1da9169d00c39aa39737a3860e4c5d31))
55
+
56
+ - Add SQLite per-branch databases and recoverable file generations
57
+ ([`a42584c`](https://github.com/earthcomfy/db-git/commit/a42584c63ea7999c13acdcf907af3a14063861f4))
58
+
59
+ - Support Git worktrees with shared database ownership
60
+ ([`701dc12`](https://github.com/earthcomfy/db-git/commit/701dc12c99c47e5d43a98bd4cd63bf805789a86b))
61
+
62
+
63
+ ## v0.2.0 (2026-06-08)
64
+
65
+ ### Added
66
+
67
+ - Introduced a new command `db-git url` that outputs the database connection URL
68
+ for the current or specified branch.
69
+
70
+ ### Changed
71
+
72
+ - Enhanced `config.py` to provide clearer documentation for the database URL configuration.
73
+
74
+ ## v0.1.1 (2026-06-01)
75
+
76
+ ### Changed
77
+
78
+ - Renamed project, CLI, package imports, configuration files, environment
79
+ variables, hook metadata, and local state paths to `db-git`.
80
+
81
+ ## v0.1.0 (2026-05-22)
82
+
83
+ ### Added
84
+
85
+ - Initial `db-git` command-line interface.
86
+ - Git `post-checkout` hook installation, removal, enable, disable, and dispatch
87
+ support.
88
+ - Shared database mode for saving and restoring branch-specific snapshots.
89
+ - Per-branch database mode for creating one database per git branch.
90
+ - PostgreSQL backend with `template` and `pgdump` snapshot strategies.
91
+ - Active connection handling with `terminate` and `fail` policies.
92
+ - Manual commands for `save`, `restore`, `create`, `reset`, `list`, `status`,
93
+ and `prune`.
94
+ - Snapshot metadata and local state storage under `.git/db-git/`.
95
+ - Unit, integration, and end-to-end tests for CLI, storage, git hooks,
96
+ PostgreSQL strategies, and branch database workflows.
97
+ - Nox sessions, Ruff linting/format checks, mypy type checking, pre-commit
98
+ hooks, Dependabot, and GitHub Actions CI.
db_git-0.3.0/PKG-INFO ADDED
@@ -0,0 +1,116 @@
1
+ Metadata-Version: 2.5
2
+ Name: db-git
3
+ Version: 0.3.0
4
+ Summary: Keep your database in sync with your git branches.
5
+ Project-URL: Homepage, https://github.com/earthcomfy/db-git
6
+ Project-URL: Documentation, https://earthcomfy.github.io/db-git/
7
+ Project-URL: Repository, https://github.com/earthcomfy/db-git
8
+ Project-URL: Issues, https://github.com/earthcomfy/db-git/issues
9
+ Project-URL: Changelog, https://github.com/earthcomfy/db-git/blob/main/CHANGELOG.md
10
+ Author: Hana Belay
11
+ License-Expression: MIT
12
+ License-File: LICENSE
13
+ Keywords: branching,cli,database,developer-tools,git,migrations,postgresql,snapshot
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Environment :: Console
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Database
23
+ Classifier: Topic :: Software Development :: Version Control :: Git
24
+ Classifier: Topic :: Utilities
25
+ Classifier: Typing :: Typed
26
+ Requires-Python: >=3.12
27
+ Requires-Dist: psycopg[binary]>=3.3.0
28
+ Requires-Dist: rich>=14.0.0
29
+ Requires-Dist: tomlkit>=0.14.0
30
+ Requires-Dist: typer>=0.24.1
31
+ Provides-Extra: mysql
32
+ Requires-Dist: pymysql[rsa]>=1.1.1; extra == 'mysql'
33
+ Description-Content-Type: text/markdown
34
+
35
+ # db-git
36
+
37
+ [![CI](https://github.com/earthcomfy/db-git/actions/workflows/test.yml/badge.svg)](https://github.com/earthcomfy/db-git/actions/workflows/test.yml)
38
+ [![Python](https://img.shields.io/pypi/pyversions/db-git.svg)](https://pypi.org/project/db-git/)
39
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/earthcomfy/db-git/blob/main/LICENSE)
40
+
41
+ Keep your database in sync with your Git branches.
42
+
43
+ `db-git` is a developer tool for schema migrations, seed data, experimental
44
+ features, and branch switching during reviews. Its `post-checkout` hook keeps
45
+ your local database aligned with the branch you are working on.
46
+
47
+ **[Documentation](https://earthcomfy.github.io/db-git/)** ·
48
+ [Browse docs in GitHub](https://github.com/earthcomfy/db-git/tree/main/docs) ·
49
+ [Release notes](https://github.com/earthcomfy/db-git/blob/main/CHANGELOG.md)
50
+
51
+ ## Features
52
+
53
+ - Automatic database handling on Git checkout.
54
+ - **Shared mode:** save and restore branch-specific snapshots.
55
+ - **Per-branch mode:** keep an independent database for each branch.
56
+ - Launch applications and migrations with `db-git run -- <command>`.
57
+ - Named checkpoints, history, and explicit retention in shared mode.
58
+ - Git worktrees in per-branch mode.
59
+ - Read-only diagnostics and recoverable database operations.
60
+ - Checkout still completes if database handling fails, with recovery guidance.
61
+
62
+ ## Supported databases
63
+
64
+ | Database | Modes | Strategy |
65
+ | --- | --- | --- |
66
+ | PostgreSQL | Shared and per-branch | `template` or `pgdump` |
67
+ | MySQL 8.0 / 8.4 | Shared and per-branch | `mysqldump` |
68
+ | SQLite | Per-branch | Online backup |
69
+
70
+ See the [database guides](https://earthcomfy.github.io/db-git/#choose-your-database)
71
+ for required privileges, client tools, and engine-specific limitations.
72
+
73
+ ## Quick start
74
+
75
+ Requires Python 3.12+, Git, and an existing local development database.
76
+ For PostgreSQL:
77
+
78
+ ```bash
79
+ uv tool install db-git # or pip install db-git
80
+
81
+ # Run inside your application's Git repository.
82
+ db-git init --database-url postgresql://localhost/myapp --mode per-branch
83
+
84
+ git checkout -b feature/auth
85
+ db-git run -- npm run dev # replace with your application's command
86
+ ```
87
+
88
+ Install the hook during initialization. Your application must read `DATABASE_URL`;
89
+ restart it through `db-git run` after switching branches. The default branch keeps
90
+ the seed database, while other branches receive separate copies.
91
+
92
+ For MySQL, install `uv tool install 'db-git[mysql]'` and follow the
93
+ [MySQL guide](https://github.com/earthcomfy/db-git/blob/main/docs/databases/mysql.md).
94
+ For SQLite, follow the [SQLite guide](https://github.com/earthcomfy/db-git/blob/main/docs/databases/sqlite.md).
95
+
96
+ ## Learn more
97
+
98
+ - [Choose shared or per-branch mode](https://github.com/earthcomfy/db-git/blob/main/docs/concepts/modes.md)
99
+ - [Run applications and migrations](https://github.com/earthcomfy/db-git/blob/main/docs/guides/applications.md)
100
+ - [Work with Git worktrees](https://github.com/earthcomfy/db-git/blob/main/docs/guides/worktrees.md)
101
+ - [Save checkpoints and inspect history](https://github.com/earthcomfy/db-git/blob/main/docs/guides/checkpoints.md)
102
+ - [Command reference](https://github.com/earthcomfy/db-git/blob/main/docs/reference/commands.md)
103
+ - [Configuration](https://github.com/earthcomfy/db-git/blob/main/docs/reference/configuration.md)
104
+ - [Troubleshooting](https://github.com/earthcomfy/db-git/blob/main/docs/troubleshooting.md)
105
+ - [Recovery](https://github.com/earthcomfy/db-git/blob/main/docs/guides/recovery.md)
106
+
107
+ ## Contributing
108
+
109
+ See the [development guide](https://github.com/earthcomfy/db-git/blob/main/docs/contributing/development.md)
110
+ for dependencies and tests, and the
111
+ [documentation guide](https://github.com/earthcomfy/db-git/blob/main/docs/contributing/documentation.md)
112
+ for local preview and publishing.
113
+
114
+ ## License
115
+
116
+ [MIT](https://github.com/earthcomfy/db-git/blob/main/LICENSE)
db_git-0.3.0/README.md ADDED
@@ -0,0 +1,82 @@
1
+ # db-git
2
+
3
+ [![CI](https://github.com/earthcomfy/db-git/actions/workflows/test.yml/badge.svg)](https://github.com/earthcomfy/db-git/actions/workflows/test.yml)
4
+ [![Python](https://img.shields.io/pypi/pyversions/db-git.svg)](https://pypi.org/project/db-git/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/earthcomfy/db-git/blob/main/LICENSE)
6
+
7
+ Keep your database in sync with your Git branches.
8
+
9
+ `db-git` is a developer tool for schema migrations, seed data, experimental
10
+ features, and branch switching during reviews. Its `post-checkout` hook keeps
11
+ your local database aligned with the branch you are working on.
12
+
13
+ **[Documentation](https://earthcomfy.github.io/db-git/)** ·
14
+ [Browse docs in GitHub](https://github.com/earthcomfy/db-git/tree/main/docs) ·
15
+ [Release notes](https://github.com/earthcomfy/db-git/blob/main/CHANGELOG.md)
16
+
17
+ ## Features
18
+
19
+ - Automatic database handling on Git checkout.
20
+ - **Shared mode:** save and restore branch-specific snapshots.
21
+ - **Per-branch mode:** keep an independent database for each branch.
22
+ - Launch applications and migrations with `db-git run -- <command>`.
23
+ - Named checkpoints, history, and explicit retention in shared mode.
24
+ - Git worktrees in per-branch mode.
25
+ - Read-only diagnostics and recoverable database operations.
26
+ - Checkout still completes if database handling fails, with recovery guidance.
27
+
28
+ ## Supported databases
29
+
30
+ | Database | Modes | Strategy |
31
+ | --- | --- | --- |
32
+ | PostgreSQL | Shared and per-branch | `template` or `pgdump` |
33
+ | MySQL 8.0 / 8.4 | Shared and per-branch | `mysqldump` |
34
+ | SQLite | Per-branch | Online backup |
35
+
36
+ See the [database guides](https://earthcomfy.github.io/db-git/#choose-your-database)
37
+ for required privileges, client tools, and engine-specific limitations.
38
+
39
+ ## Quick start
40
+
41
+ Requires Python 3.12+, Git, and an existing local development database.
42
+ For PostgreSQL:
43
+
44
+ ```bash
45
+ uv tool install db-git # or pip install db-git
46
+
47
+ # Run inside your application's Git repository.
48
+ db-git init --database-url postgresql://localhost/myapp --mode per-branch
49
+
50
+ git checkout -b feature/auth
51
+ db-git run -- npm run dev # replace with your application's command
52
+ ```
53
+
54
+ Install the hook during initialization. Your application must read `DATABASE_URL`;
55
+ restart it through `db-git run` after switching branches. The default branch keeps
56
+ the seed database, while other branches receive separate copies.
57
+
58
+ For MySQL, install `uv tool install 'db-git[mysql]'` and follow the
59
+ [MySQL guide](https://github.com/earthcomfy/db-git/blob/main/docs/databases/mysql.md).
60
+ For SQLite, follow the [SQLite guide](https://github.com/earthcomfy/db-git/blob/main/docs/databases/sqlite.md).
61
+
62
+ ## Learn more
63
+
64
+ - [Choose shared or per-branch mode](https://github.com/earthcomfy/db-git/blob/main/docs/concepts/modes.md)
65
+ - [Run applications and migrations](https://github.com/earthcomfy/db-git/blob/main/docs/guides/applications.md)
66
+ - [Work with Git worktrees](https://github.com/earthcomfy/db-git/blob/main/docs/guides/worktrees.md)
67
+ - [Save checkpoints and inspect history](https://github.com/earthcomfy/db-git/blob/main/docs/guides/checkpoints.md)
68
+ - [Command reference](https://github.com/earthcomfy/db-git/blob/main/docs/reference/commands.md)
69
+ - [Configuration](https://github.com/earthcomfy/db-git/blob/main/docs/reference/configuration.md)
70
+ - [Troubleshooting](https://github.com/earthcomfy/db-git/blob/main/docs/troubleshooting.md)
71
+ - [Recovery](https://github.com/earthcomfy/db-git/blob/main/docs/guides/recovery.md)
72
+
73
+ ## Contributing
74
+
75
+ See the [development guide](https://github.com/earthcomfy/db-git/blob/main/docs/contributing/development.md)
76
+ for dependencies and tests, and the
77
+ [documentation guide](https://github.com/earthcomfy/db-git/blob/main/docs/contributing/documentation.md)
78
+ for local preview and publishing.
79
+
80
+ ## License
81
+
82
+ [MIT](https://github.com/earthcomfy/db-git/blob/main/LICENSE)
@@ -0,0 +1,26 @@
1
+ # Choose a mode
2
+
3
+ ## Shared Mode
4
+
5
+ PostgreSQL shared mode keeps the name from the configured `database_url`.
6
+ MySQL shared mode selects a fresh working database URL on restore; restart apps
7
+ through `db-git run` afterward.
8
+
9
+ Use this when:
10
+
11
+ - You want one active working database and branch-specific snapshots
12
+ - You restart applications after restoring or switching branches
13
+
14
+ ## Per-Branch Mode
15
+
16
+ Per-branch mode creates a separate database for each branch. The configured
17
+ default branch keeps the original database name and acts as the seed database.
18
+
19
+ Use this when:
20
+
21
+ - You want branch databases to persist independently
22
+ - You prefer creating new databases over repeatedly restoring one shared
23
+ database
24
+
25
+ SQLite supports only per-branch mode. Multiple Git worktrees also require
26
+ per-branch mode. See [worktrees](../guides/worktrees.md) for setup and shared state.
@@ -0,0 +1,67 @@
1
+ # Development
2
+
3
+ Install dependencies:
4
+
5
+ ```bash
6
+ uv sync --group dev
7
+ ```
8
+
9
+ Run checks:
10
+
11
+ ```bash
12
+ uv run ruff check .
13
+ uv run mypy src
14
+ uv run pytest tests/unit tests/sqlite
15
+ ```
16
+
17
+ For MySQL development, install its optional driver and Oracle MySQL clients, then
18
+ run the Docker-backed workflow and recovery tests against each supported server:
19
+
20
+ ```bash
21
+ uv sync --group dev --extra mysql
22
+ DB_GIT_TEST_MYSQL_IMAGE=mysql:8.0 uv run pytest tests/mysql
23
+ DB_GIT_TEST_MYSQL_IMAGE=mysql:8.4 uv run pytest tests/mysql
24
+ ```
25
+
26
+ CI runs both MySQL workflows, stored-object cloning, and recovery tests on
27
+ Python 3.12 and 3.13 against MySQL 8.0 and 8.4.
28
+
29
+ Run the full nox suite:
30
+
31
+ ```bash
32
+ nox
33
+ ```
34
+
35
+ ## Run the CI matrix locally
36
+
37
+ To catch differences between macOS tools and the Linux CI environment, use the
38
+ local runner from the repository root with Docker running:
39
+
40
+ ```bash
41
+ python3 scripts/ci/local.py
42
+ ```
43
+
44
+ It builds an Ubuntu 24.04 image, includes uncommitted source changes, and runs
45
+ the same nox sessions for Python 3.12/3.13, PostgreSQL 13–17, and MySQL 8.0/8.4.
46
+ PostgreSQL sessions select their matching client binaries; MySQL uses Ubuntu's
47
+ Oracle MySQL 8.0 clients. The checkout and its virtual environments stay untouched.
48
+ Logs and a JSON result summary are written to the temporary directory printed
49
+ by the runner. The command exits nonzero when a session fails.
50
+
51
+ The default is one job at a time with an x86-64 Linux test runner. GitHub gives
52
+ each matrix job its own machine; local jobs share Docker's CPU and memory with
53
+ your other containers. On Apple Silicon, emulation adds overhead, and concurrent
54
+ database suites can encounter transient connection failures. Select a specific
55
+ session, or increase concurrency when your machine has sufficient resources:
56
+
57
+ ```bash
58
+ python3 scripts/ci/local.py --jobs 4
59
+ python3 scripts/ci/local.py --session "integration-3.12(pg_image='postgres:15')"
60
+ ```
61
+
62
+ The runner uses the local Docker socket to create disposable test databases.
63
+ It validates test jobs, not GitHub authentication, caching, Pages deployment,
64
+ or PyPI publication. Database image architecture follows the Docker daemon;
65
+ the hosted runner's exact package patch versions may also differ over time.
66
+
67
+ See [documentation development](documentation.md) to preview and publish the site.
@@ -0,0 +1,55 @@
1
+ # Documentation development and publishing
2
+
3
+ The site uses MkDocs with the Material theme. Edit Markdown files under `docs/`
4
+ and update `nav` in the root `mkdocs.yml` when adding or moving pages.
5
+
6
+ ## Preview locally
7
+
8
+ From the repository root, run:
9
+
10
+ ```bash
11
+ uv tool run --with-requirements requirements-docs.txt mkdocs serve
12
+ ```
13
+
14
+ Open the local URL printed by MkDocs. The preview reloads when pages change.
15
+ Documentation tools run separately from the application's dependencies.
16
+
17
+ ## Validate the site
18
+
19
+ ```bash
20
+ uv tool run --with-requirements requirements-docs.txt mkdocs build --strict
21
+ ```
22
+
23
+ The build writes static HTML to `site/`, which is ignored by Git. Strict validation
24
+ fails on missing pages, broken relative links, and invalid internal anchors.
25
+ Review both desktop and mobile navigation when changing the theme or layout.
26
+
27
+ Keep the README short and link to the detailed guides. Document behavior changes
28
+ alongside code, especially engine-specific limits and recovery guarantees.
29
+ The local roadmap is excluded from the generated site and search index.
30
+
31
+ ## Publish with GitHub Pages
32
+
33
+ The `docs` GitHub Actions workflow validates documentation on pull requests and
34
+ pushes to `main`. Only pushes to `main` or manual runs on `main` publish the site;
35
+ pull requests never deploy it.
36
+
37
+ For the first deployment, a repository administrator must select **Settings →
38
+ Pages → Build and deployment → Source → GitHub Actions**. Then push the site
39
+ changes to `main`, or run the `docs` workflow manually once it exists there.
40
+ If the `github-pages` environment requires approval, approve its deployment.
41
+
42
+ The configured URL is <https://earthcomfy.github.io/db-git/>. Publication requires
43
+ the repository's Pages settings and the workflow to succeed; a local build does
44
+ not publish anything.
45
+
46
+ The workflow uses GitHub's Pages artifact deployment and does not maintain a
47
+ `gh-pages` branch. If the repository owner/name or domain changes, update
48
+ `site_url` in `mkdocs.yml`, the README docs link, and the package documentation URL.
49
+
50
+ ## Documentation versions
51
+
52
+ The site publishes from `main` independently of package releases, so documentation
53
+ corrections can go live without a new PyPI release. There is one documentation
54
+ site without a version selector. When a feature needs a version distinction, add
55
+ an "Added in version X" note beside that feature using its actual release version.