Files
philip-cat 6dedb5469f Move seed.sql out of migrations and add SEO structured data
- Relocate seed.sql to scripts/ so wrangler d1 migrations apply
  doesn't treat it as a migration; update package.json, setup.mjs,
  README, and all AGENTS.md references.
- Add src/lib/schema-org.ts builders (LocalBusiness, FAQPage,
  BlogPosting, BreadcrumbList) and emit JSON-LD via Base.astro.
- Add lastmod to sitemap entries.
- Set real site domain, worker route, and D1/KV ids.
- Improve image loading hints and heading semantics across site
  components; switch BlogIndex to client:idle.
2026-09-13 16:21:59 +08:00

38 lines
2.2 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# migrations/AGENTS.md
## Purpose
Cloudflare D1 的 schema migration SQL。
## Ownership
- 擁有 `migrations/` 全部 SQL 同 `migrations/meta/`(產生檔)。
- Drizzle schema 定義喺 `src/db/schema.ts`(見 `src/db/AGENTS.md`)。
- 種子資料 `seed.sql``scripts/`(由 root AGENTS.md 擁有)。
## Local Contracts
- **Migration 由工具產生**`0000_*.sql``0001_*.sql``0002_*.sql``npm run db:generate`drizzle-kit)依 `schema.ts` 產生;`migrations/meta/` 係產生檔。**唔好手改**呢啲檔或 meta。`0002_*.sql` 加咗 `posts.focus_keyword``blog_keywords` 表。
- **`migrations/` 內所有 `.sql` 都會被當成 migration**`wrangler d1 migrations apply` 會套用 `migrations_dir``wrangler.jsonc`,現為 `migrations`)內全部 `.sql`。所以**種子資料一定要放喺 `migrations/` 以外**(現時 `scripts/seed.sql`),否則 `db:migrate` 會連 seed 一齊種。
- **Migration 唔會喺 CI 執行**Cloudflare Workers Builds 只跑 build + deploy;改 schema 後要手動 `npm run db:migrate`(雲端)。
- **指令**(本機用 `:local`,雲端省略):
- `npm run db:generate` — 由 schema 產生 migration
- `npm run db:migrate:local` / `npm run db:migrate` — 套用 migration
- `npm run db:seed:local` / `npm run db:seed` — 匯入種子(`scripts/seed.sql`
- **Seed 內容**`scripts/seed.sql`,全部 `INSERT OR REPLACE`、可重複跑):公司資料(`site_settings`)、首頁內容(`content_items`service/feature/step/faq)、`cases`、一篇示範 `posts`、三個示範 `blog_keywords``pending`);另有 7 個 `ai_*` AI 設定 keys(獨立 seed block)。
- DB 名稱 `yingfung-solar-db`binding 喺 `wrangler.jsonc``database_id` / KV `id``npm run setup``db:create` / `kv:create` 寫入)。
## Work Guidance
- 改 schema → 先 `db:generate`,再 `db:migrate:local`;改 seed → 直接改 `scripts/seed.sql``db:seed:local`
- 新增 setting key 時同步更新 `src/data/settings-fields.ts`
## Verification
- `npm run db:migrate:local && npm run db:seed:local`,再用 `npm run db:studio` 或 SQL 查證。
- `npm run build`
## Child DOX Index
無。