feat: PostgreSQL移行の第一段階 — 開発環境・migration互換・テストプロファイル (#62)#66
Merged
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- .env.pgsql.example: pgsql接続のローカル開発既定値 - scripts/pgsql-dev.sh: podman/docker でのコンテナ起動/停止/破棄。 起動時にテスト用DB quotebuilder_test も作成する Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
PostgreSQLはHAVINGでSELECT別名を参照できないため、
having('n','>',1) を havingRaw('count(*) > 1') に変更。
pgsqlでmigrate:fresh/migrate:resetの全件通過を確認、
SQLite側もFeature test 201件で回帰なし。
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- phpunit.pgsql.xml: scripts/pgsql-dev.sh の quotebuilder_test へ
force接続するプロファイル。composer run test:pgsql で実行
- BackupStorageTest を pgsql プロファイル対応に修正
- acting user を default接続切替前に作成(切替後だと手書き
スキーマの一時DBへinsertされ失敗)
- 手書き backup_audit_logs を実migrationと同じ列構成に更新
- tearDown で database.default を復元。切替したままだと
RefreshDatabase のロールバックが一時SQLiteへ向かい、pgsql側の
トランザクション残置で次テストの migrate がロック待ちハング
- pgsql / sqlite 両プロファイルで 201件 pass を確認
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
PostgreSQL 移行(Issue #62)の第一段階として、開発環境・migration・テストプロファイルを整備し、「PostgreSQL で migrate と Feature tests を通す」ための足場を追加しています。
Changes:
- PostgreSQL 開発用の env/example とコンテナ操作スクリプトを追加
- PostgreSQL で動かない migration の HAVING 句(SELECT 別名参照)を互換な形に修正
- PostgreSQL 実行用 PHPUnit プロファイルと composer スクリプトを追加し、関連テストを調整
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/Feature/BackupStorageTest.php | pgsql プロファイルでも安定して動くよう、接続切替タイミングと手書き SQLite スキーマを実 migration に整合 |
| scripts/pgsql-dev.sh | podman/docker で開発用 PostgreSQL コンテナを start/stop/destroy/status できるユーティリティを追加 |
| README.md | DB 方針(PostgreSQL を primary DB へ移行予定、SQLite は legacy 扱い)に記述を統一 |
| phpunit.pgsql.xml | PostgreSQL 向け PHPUnit 実行プロファイル(quotebuilder_test 接続)を追加 |
| database/migrations/2026_07_01_000000_create_customer_signatures_table.php | PostgreSQL 互換の HAVING 条件に修正(別名参照を排除) |
| composer.json | composer run test:pgsql を追加し、pgsql プロファイルでの PHPUnit 実行導線を追加 |
| .env.pgsql.example | ローカル PostgreSQL 接続の既定値を提供する env サンプルを追加 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+30
to
+35
| <env name="DB_CONNECTION" value="pgsql" force="true"/> | ||
| <env name="DB_HOST" value="127.0.0.1" force="true"/> | ||
| <env name="DB_PORT" value="5432" force="true"/> | ||
| <env name="DB_DATABASE" value="quotebuilder_test" force="true"/> | ||
| <env name="DB_USERNAME" value="quotebuilder" force="true"/> | ||
| <env name="DB_PASSWORD" value="quotebuilder" force="true"/> |
Owner
Author
There was a problem hiding this comment.
修正完了: DB_HOST/DB_PORT/DB_USERNAME/DB_PASSWORD の force を外し環境変数で上書き可能にしました(commit a49cd5b)。DB_CONNECTION と DB_DATABASE は、誤上書きで RefreshDatabase が開発DBを消すのを防ぐため force 固定を維持しています。
Copilot レビュー指摘対応。DB_HOST/DB_PORT/DB_USERNAME/DB_PASSWORD の force="true" を外し、CI やローカルで接続先を環境変数で差し替え可能にする。 DB_CONNECTION と DB_DATABASE は誤って開発DBへ向けて RefreshDatabase が 実データを消さないよう force 固定を維持する。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
Issue #62(PostgreSQL 移行)の第一実装単位「PostgreSQL で
migrate:freshと Feature test を通す」を実装する。変更内容
.env.pgsql.example(pgsql 接続のローカル既定値)とscripts/pgsql-dev.sh(podman/docker で postgres:17-alpine の start/stop/destroy/status。start 時にテスト用 DBquotebuilder_testも作成)を追加customer_signatures移行の重複検出をhaving('n','>',1)→havingRaw('count(*) > 1')に修正。PostgreSQL は HAVING で SELECT 別名を参照できない(SQLSTATE 42703)phpunit.pgsql.xmlプロファイルとcomposer run test:pgsqlを追加。BackupStorageTestを pgsql 実行に対応backup_audit_logsスキーマを実 migration の列構成に一致database.defaultを復元(切替したままだと RefreshDatabase のロールバックが一時 SQLite へ向かい、pgsql 側トランザクションの残置ロックで次テストの migrate がハング)検証
migrate:fresh/migrate:reset/migrate全件通過composer run test:pgsql: 201/201 passcomposer test(SQLite :memory:): 201/201 pass(回帰なし)composer validate通過スコープ外(後続)
setval())Closes 参照: #62(クローズはせず、移行計画の第一段階として紐づけ)
🤖 Generated with Claude Code