Skip to content

Commit 3688b00

Browse files
committed
fix: Add --package flag to pgpm deploy to avoid interactive prompt
The pgpm deploy command was showing an interactive prompt to choose a package instead of actually deploying. This fix adds a 'package' parameter to the seed.pgpm() adapter that passes --package to pgpm deploy, avoiding the interactive prompt in CI/non-interactive environments.
1 parent 4336986 commit 3688b00

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

src/pysql_test/seed/pgpm.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class PgpmSeedAdapter:
3535
def __init__(
3636
self,
3737
module_path: str | None = None,
38+
package: str | None = None,
3839
deploy_args: list[str] | None = None,
3940
cache: bool = False,
4041
) -> None:
@@ -43,10 +44,12 @@ def __init__(
4344
4445
Args:
4546
module_path: Path to the pgpm module directory (defaults to cwd)
47+
package: Package name to deploy (avoids interactive prompt)
4648
deploy_args: Additional arguments to pass to pgpm deploy
4749
cache: Whether to enable caching (not yet implemented)
4850
"""
4951
self._module_path = module_path
52+
self._package = package
5053
self._deploy_args = deploy_args or []
5154
self._cache = cache
5255

@@ -76,6 +79,8 @@ def seed(self, ctx: SeedContext) -> None:
7679

7780
# Build pgpm deploy command
7881
cmd = ["pgpm", "deploy", "--yes", "--verbose"]
82+
if self._package:
83+
cmd.extend(["--package", self._package])
7984
cmd.extend(self._deploy_args)
8085

8186
logger.info(f"Running pgpm deploy in {cwd}")
@@ -111,6 +116,7 @@ def seed(self, ctx: SeedContext) -> None:
111116

112117
def pgpm(
113118
module_path: str | None = None,
119+
package: str | None = None,
114120
deploy_args: list[str] | None = None,
115121
cache: bool = False,
116122
) -> PgpmSeedAdapter:
@@ -122,6 +128,7 @@ def pgpm(
122128
123129
Args:
124130
module_path: Path to the pgpm module directory (defaults to cwd)
131+
package: Package name to deploy (avoids interactive prompt)
125132
deploy_args: Additional arguments to pass to pgpm deploy
126133
cache: Whether to enable caching
127134
@@ -131,12 +138,12 @@ def pgpm(
131138
Example:
132139
# Deploy migrations from a specific module
133140
seed_adapters = [
134-
seed.pgpm(module_path="./packages/my-module")
141+
seed.pgpm(module_path="./packages/my-module", package="my-module")
135142
]
136143
137144
# Deploy with additional arguments
138145
seed_adapters = [
139-
seed.pgpm(module_path="./my-module", deploy_args=["--verbose"])
146+
seed.pgpm(module_path="./my-module", package="my-module", deploy_args=["--verbose"])
140147
]
141148
"""
142-
return PgpmSeedAdapter(module_path=module_path, deploy_args=deploy_args, cache=cache)
149+
return PgpmSeedAdapter(module_path=module_path, package=package, deploy_args=deploy_args, cache=cache)

tests/test_pgpm_integration.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
# Path to the pre-scaffolded pgpm workspace fixture
1919
FIXTURE_PATH = Path(__file__).parent / "fixtures" / "pgpm-workspace" / "packages" / "test-module"
20+
PACKAGE_NAME = "test-module"
2021

2122

2223
@pytest.fixture
@@ -29,7 +30,7 @@ def pgpm_db():
2930
"""
3031
conn = get_connections(
3132
seed_adapters=[
32-
seed.pgpm(module_path=str(FIXTURE_PATH))
33+
seed.pgpm(module_path=str(FIXTURE_PATH), package=PACKAGE_NAME)
3334
]
3435
)
3536
db = conn.db

0 commit comments

Comments
 (0)