pgdevkit 0.7.0__py3-none-any.whl → 0.7.2__py3-none-any.whl
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.
- pgdevkit/testdb/__init__.py +2 -0
- pgdevkit/testdb/api.py +14 -0
- pgdevkit/testdb/naming.py +10 -1
- {pgdevkit-0.7.0.dist-info → pgdevkit-0.7.2.dist-info}/METADATA +8 -1
- {pgdevkit-0.7.0.dist-info → pgdevkit-0.7.2.dist-info}/RECORD +7 -7
- {pgdevkit-0.7.0.dist-info → pgdevkit-0.7.2.dist-info}/WHEEL +1 -1
- {pgdevkit-0.7.0.dist-info → pgdevkit-0.7.2.dist-info}/entry_points.txt +0 -0
pgdevkit/testdb/__init__.py
CHANGED
pgdevkit/testdb/api.py
CHANGED
|
@@ -189,6 +189,20 @@ def find_orphaned_dbs(project_root: Path | None = None) -> list[str]:
|
|
|
189
189
|
return asyncio.run(_find_orphaned_dbs(config))
|
|
190
190
|
|
|
191
191
|
|
|
192
|
+
def workspace_db_names(project_root: Path | None = None) -> frozenset[str]:
|
|
193
|
+
"""Every DB name this exact workspace (the branch currently checked out
|
|
194
|
+
at `project_root`) owns: its main workspace DB plus one
|
|
195
|
+
`<main>{suffix}` sibling per configured `extra_db_suffixes` entry. The
|
|
196
|
+
single-workspace analog of what `find_orphaned_dbs` computes across
|
|
197
|
+
every *live* worktree -- for a caller that wants "which DBs belong to
|
|
198
|
+
this one worktree right now" (e.g. to drop them before removing the
|
|
199
|
+
worktree itself), as opposed to a whole-project orphan sweep. Engine
|
|
200
|
+
(postgres/mssql) doesn't affect naming, so this doesn't dispatch on it."""
|
|
201
|
+
config = load_config(project_root)
|
|
202
|
+
branch = current_branch(config.root)
|
|
203
|
+
return frozenset(expected_db_names(config, [branch]))
|
|
204
|
+
|
|
205
|
+
|
|
192
206
|
def clean_testdb(project_root: Path | None = None, all: bool = False, orphaned: bool = False) -> None:
|
|
193
207
|
"""Drop this workspace's database. With all=True, drop every database
|
|
194
208
|
belonging to this project (matched by its name-slug prefix), across
|
pgdevkit/testdb/naming.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import hashlib
|
|
4
|
+
import os
|
|
4
5
|
import re
|
|
5
6
|
import subprocess
|
|
6
7
|
from pathlib import Path
|
|
@@ -25,7 +26,15 @@ def slugify(value: str) -> str:
|
|
|
25
26
|
|
|
26
27
|
|
|
27
28
|
def current_branch(cwd: Path | None = None) -> str:
|
|
28
|
-
"""Return the branch checked out in the git worktree rooted at cwd.
|
|
29
|
+
"""Return the branch checked out in the git worktree rooted at cwd.
|
|
30
|
+
|
|
31
|
+
PGDEVKIT_TESTDB_BRANCH overrides this when set -- lets concurrent CI
|
|
32
|
+
checkouts (which all otherwise resolve to detached-HEAD "HEAD") get
|
|
33
|
+
distinct database names on a shared test-DB container.
|
|
34
|
+
"""
|
|
35
|
+
override = os.environ.get("PGDEVKIT_TESTDB_BRANCH")
|
|
36
|
+
if override:
|
|
37
|
+
return override
|
|
29
38
|
result = subprocess.run(
|
|
30
39
|
["git", "rev-parse", "--abbrev-ref", "HEAD"],
|
|
31
40
|
cwd=cwd,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: pgdevkit
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.2
|
|
4
4
|
Summary: A helper for developing with Postgres
|
|
5
5
|
Requires-Python: >=3.14
|
|
6
6
|
Requires-Dist: docker>=7.1.0
|
|
@@ -252,6 +252,13 @@ belongs to a live worktree too:
|
|
|
252
252
|
extra_db_suffixes = ["_myservice"]
|
|
253
253
|
```
|
|
254
254
|
|
|
255
|
+
`pgdevkit.testdb.workspace_db_names(project_root=None)` is the
|
|
256
|
+
single-workspace analog of `find_orphaned_dbs()`: it returns the exact set
|
|
257
|
+
of DB names (main + any `extra_db_suffixes`) owned by the branch currently
|
|
258
|
+
checked out at `project_root`, without touching Postgres or diffing against
|
|
259
|
+
other worktrees. Useful for a caller that's about to remove one specific
|
|
260
|
+
worktree and wants to know exactly which DB(s) go with it.
|
|
261
|
+
|
|
255
262
|
Container connection defaults (`localhost:54322`, `postgres`/`testpwd`) can
|
|
256
263
|
be overridden with `PGDEVKIT_TESTDB_HOST`, `PGDEVKIT_TESTDB_PORT`,
|
|
257
264
|
`PGDEVKIT_TESTDB_USER`, `PGDEVKIT_TESTDB_PASSWORD`. Before touching the
|
|
@@ -26,13 +26,13 @@ pgdevkit/db/loader.py,sha256=0Swmp0h0s7I4acG0Dv3cem2YD4lFvq8aFEbFQPPQrxg,616
|
|
|
26
26
|
pgdevkit/db/model.py,sha256=ntuXonq-SCGkbNw-lvdMS5VuzLjxYRT8O6xaVqiw56I,980
|
|
27
27
|
pgdevkit/db/mssql_crud.py,sha256=yN4izZ0fsFwAs14008JECHH4dqjNbdHUHGEG8kidyNs,11374
|
|
28
28
|
pgdevkit/db/mssql_sql.py,sha256=DO3UMsTFN9pg0tNdaPGb0wf6lWlHGcqwqzkrGVhJF2g,2292
|
|
29
|
-
pgdevkit/testdb/__init__.py,sha256=
|
|
29
|
+
pgdevkit/testdb/__init__.py,sha256=tphuORo4t0QHQp_gFi6ZHXXgd32w6qUoKlaQCab6izA,366
|
|
30
30
|
pgdevkit/testdb/_docker.py,sha256=kj_0xrGO_mxHlK83ilsB-yE0ELX1kpH22ruYrS-N3iU,1467
|
|
31
|
-
pgdevkit/testdb/api.py,sha256=
|
|
31
|
+
pgdevkit/testdb/api.py,sha256=13YgTz6hPcYWfsUlQJhJ7k20-W_4hzepedVaT8gWhxI,9709
|
|
32
32
|
pgdevkit/testdb/config.py,sha256=NyeskDeThUgwOuxiMgHVnUOiHW-xVO9s2lJQoJcQwW4,2839
|
|
33
33
|
pgdevkit/testdb/constants.py,sha256=oykc7xoX2R0ykhjXpqIdwkZoeHcScme8S2UPYvi_d_w,1718
|
|
34
34
|
pgdevkit/testdb/container.py,sha256=PD2xUksIlAWXXus2VtAil_8UnwlG5DUcyUvbZx0eZTg,3123
|
|
35
|
-
pgdevkit/testdb/naming.py,sha256=
|
|
35
|
+
pgdevkit/testdb/naming.py,sha256=iHZVYdBQjHOD5sihgmZFe2qOC1djgBb6iP6R8wLUfL0,4377
|
|
36
36
|
pgdevkit/testdb/query.py,sha256=iYpy_EoYIq5USfwr6pNktmDjcGi_yQx0vHvjHZNGRr0,3854
|
|
37
37
|
pgdevkit/testdb/schema.py,sha256=XYBK3xyay98a5gzFW6SAQ336Jge-NhOQhildSQDOaf4,15101
|
|
38
38
|
pgdevkit/testdb/mssql/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
|
|
@@ -43,7 +43,7 @@ pgdevkit/docs/database-layout.md,sha256=j9N8GuT63D2oVf9rIOEv8GTWs4yTtjZTGH-zM5Wr
|
|
|
43
43
|
pgdevkit/skills/pgdevkit/SKILL.md,sha256=ADqEaQtMJPUUAiieqokzUUmIf27bWWJNB1ZvsfgiKAE,12205
|
|
44
44
|
pgdevkit/skills/pgdevkit/references/dynamic-sql.md,sha256=aTR1sx81moiTwaMaiOecaqk-9rT8y5Zxz7W1BoC3vK0,2774
|
|
45
45
|
pgdevkit/skills/pgdevkit/references/temporal-tables.md,sha256=LwZnItvQWI7bB0oRHxIfUc0ynnq7N0V5Mnv-QHvFN3Q,1364
|
|
46
|
-
pgdevkit-0.7.
|
|
47
|
-
pgdevkit-0.7.
|
|
48
|
-
pgdevkit-0.7.
|
|
49
|
-
pgdevkit-0.7.
|
|
46
|
+
pgdevkit-0.7.2.dist-info/METADATA,sha256=6LQs_7tl-vQ-I8WnTSpl7uRIesuDropRBTL8fcE22GE,20367
|
|
47
|
+
pgdevkit-0.7.2.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
48
|
+
pgdevkit-0.7.2.dist-info/entry_points.txt,sha256=FK2P55lf0WaGlOZJIINOGgCt8WB7ep0OnPsgnrp80bg,42
|
|
49
|
+
pgdevkit-0.7.2.dist-info/RECORD,,
|
|
File without changes
|