Skip to content

feat: PostgreSQLをprimary DBに移行する#64

Open
strnh wants to merge 7 commits into
mainfrom
feature/62-postgresql-primary
Open

feat: PostgreSQLをprimary DBに移行する#64
strnh wants to merge 7 commits into
mainfrom
feature/62-postgresql-primary

Conversation

@strnh

@strnh strnh commented Jul 10, 2026

Copy link
Copy Markdown
Owner

概要

quotebuilderのprimary DBをSQLiteからPostgreSQL 17へ移行し、receiptbuilderとDBドライバ・開発構成を揃えます。

Closes #62

変更内容

  • .env.example / database・queue設定の既定接続をpgsqlへ変更
  • receiptbuilderと同型のCompose構成を追加(同時起動用にhost portは55433
  • 開発DBとPHPUnit用DBを分離し、初期化スクリプトをPostgreSQL対応
  • PostgreSQLで通らないmigrationのHAVING別名参照を修正
  • JSON restore後にPostgreSQL sequenceを最大IDへ同期
  • PostgreSQL 17 serviceでmigrationとFeature testを行うGitHub Actionsを追加
  • frontendの型検査・production buildを行うGitHub Actionsを追加
  • SQLiteからの退避・JSON移行手順とバックアップ制約をREADMEへ追記

スコープ(実ファイル)

  • DB/環境: .env.example, config/database.php, config/queue.php, phpunit.xml, composer.json
  • PostgreSQL起動: compose.yaml, docker/postgres/init/01-create-test-database.sql, scripts/init.sh, scripts/init-test.sh
  • 互換修正: database/migrations/2026_07_01_000000_create_customer_signatures_table.php, app/Services/BackupRestorer.php
  • 検証: .github/workflows/php-tests.yml, .github/workflows/ci.yml, tests/TestCase.php, tests/Feature/BackupStorageTest.php, tests/Feature/BackupTest.php
  • 文書/コメント: README.md, resources/js/data/adapters/api.ts, resources/js/data/store.ts

スコープ外

PostgreSQL向け障害復旧用フルバックアップ・リストアは独立機能として #63 に切り出しました。現PRではJSON export/importを移行経路とし、SQLiteフルバックアップはlegacy互換として維持します。

PHP 8.5要件の宣言と composer.json 制約の整合は #53 の別スコープです。現在のlockfileはSymfony 8.1(PHP 8.4.1以上)を含むため、本PRのCIは想定実行環境のPHP 8.5を使用します。

検証

  • DB接続値を force=true でテストDBへ固定する前に、SQLite互換で全202 tests / 744 assertions成功
  • focused tests: 74 tests / 309 assertions、および BackupStorageTest 13 tests / 58 assertions成功
  • vendor/bin/pint --test(変更PHPファイル)
  • npm run type-check
  • npm run build
  • bash -n scripts/init.sh scripts/init-test.sh
  • GitHub Actions Frontend checks: 成功
  • GitHub Actions PHP tests: PostgreSQL 17でmigrate:freshと全Feature test成功(最終pushでも再実行)

@strnh strnh requested a review from Copilot July 10, 2026 04:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

quotebuilder の primary DB を SQLite から PostgreSQL 17 へ移行し、開発・CI・バックアップ/リストア周りを PostgreSQL 前提に揃えるPRです(receiptbuilder と同型の開発構成・ドライバを合わせる目的)。

Changes:

  • 既定DB接続を pgsql に切り替え、開発用 PostgreSQL(Compose)と PHPUnit 用DB分離を追加
  • PostgreSQL互換のため migration の HAVING 句を修正し、JSONリストア後に sequence を最大IDへ同期する処理を追加
  • GitHub Actions で PostgreSQL 17 上の migration/Feature test を実行し、README に移行手順・制約を追記

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/Feature/BackupTest.php PostgreSQL の sequence 同期を検証するテストを追加
app/Services/BackupRestorer.php PostgreSQL の sequence を最大IDへ進める処理を追加
database/migrations/2026_07_01_000000_create_customer_signatures_table.php PostgreSQL非互換の HAVING 別名参照を修正
compose.yaml 開発用 PostgreSQL 17 サービスを追加(host port 55433)
docker/postgres/init/01-create-test-database.sql PHPUnit 用 quotebuilder_test DB 作成を追加
phpunit.xml PHPUnit の既定DBを PostgreSQL(テストDB)へ変更
scripts/init.sh 初期化で PostgreSQL 起動・待機を行うよう変更
scripts/init-test.sh テスト用セットアップを PostgreSQL 前提へ変更
.github/workflows/php-tests.yml PostgreSQL 17 サービスで migration + Feature test を実行するCIを追加
.github/workflows/ci.yml フロントエンド(type-check/build)のCIを追加
.env.example 既定DB設定を PostgreSQL(compose 55433)に変更
config/database.php DB default を pgsql に変更
config/queue.php queue batching/failed の既定DBを pgsql に変更
composer.json SQLite DB ファイル作成の post-create 処理を削除
README.md PostgreSQL 前提の説明、SQLite→PostgreSQL移行手順・制約を追記
resources/js/data/store.ts コメント上の既定バックエンド表記を PostgreSQL に更新
resources/js/data/adapters/api.ts コメント上のバックエンド表記を PostgreSQL に更新

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/Feature/BackupTest.php Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.

Comment thread compose.yaml
Comment thread phpunit.xml Outdated
Comment thread phpunit.xml Outdated
Copilot finished work on behalf of strnh July 10, 2026 05:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.

Comment thread app/Services/BackupRestorer.php Outdated
Comment thread .github/workflows/php-tests.yml
Comment thread phpunit.xml

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.

Comment thread scripts/init.sh
Comment thread scripts/init-test.sh
Comment thread tests/Feature/BackupStorageTest.php Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: postgresql 移行

3 participants