Documentation is available in Japanese and English; some sections are in Japanese only.

docs/project-metadata-bundle.md · c995b6b5673e2220501daa3f0997d0876277be82
Original reading view · Source commit and manifest

Project Metadata Bundle / プロジェクトメタデータ bundle

English companion: This document explains the current project-scoped export and import bundle format for canonical metadata. It defines which scope is included today, how database-source secrets are separated, and how preview versus apply should be used safely.

この文書は、canonical metadata の project-scoped export / import bundle についての current rule をまとめた恒久文書です。
実装メモや履歴ではなく、今どの scope を移せて、何を secret file に分離し、どう preview/apply を使うかの正本として扱います。

existing DB から output までの end-to-end 手順は existing-db-to-output.md (Mtool原本: existing-db-to-output.md) を正本にします。
この文書は stage を繰り返さず、bundle transport と secret rule の detail だけを残します。

この文書を使う場面

この文書だけで topology や mainline を再構成しないで、先に golden path の stage を確定してから detail として使います。

目的

current scope

current first slice の scope は project-core です。bundle 本体には次を含みます。

次はまだ scope 外です。

export

local compose では host 側 PHP ではなく container 内 CLI を使います。

docker compose exec -T web-admin php /var/www/mtool/scripts/export_project_metadata.php \
  --project-key=MTOOL \
  --database-sources=reporting_db,analytics_db \
  --output-dir=/tmp/mtool-project-metadata-bundle-MTOOL \
  --requested-by=manual

import

import は preview -> apply の 2 段で使います。

docker compose exec -T web-admin php /var/www/mtool/scripts/import_project_metadata.php \
  --bundle=/tmp/mtool-project-metadata-bundle-MTOOL \
  --mode=preview \
  --database-source-secrets=/tmp/mtool-project-metadata-secrets.json \
  --requested-by=manual
docker compose exec -T web-admin php /var/www/mtool/scripts/import_project_metadata.php \
  --bundle=/tmp/mtool-project-metadata-bundle-MTOOL \
  --mode=apply \
  --database-source-secrets=/tmp/mtool-project-metadata-secrets.json \
  --requested-by=manual

secret の扱い

bundle の secrets_policy は exclude-all です。bundle 本体には actual password を入れません。

secrets file format

literal password:

{
  "database_source_passwords": {
    "reporting_db": "secret-value"
  }
}

env reference:

{
  "database_source_passwords": {
    "reporting_db": {
      "password_env": "REPORTING_DB_PASSWORD"
    }
  }
}

database source import rule

推奨フロー

  1. export する
  2. 必要なら database-source-secrets.template.json を元に secret file を作る
  3. preview で warning と apply plan を確認する
  4. 問題がなければ apply を流す

関連文書