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.
This commit is contained in:
@@ -2,28 +2,29 @@
|
||||
|
||||
## Purpose
|
||||
|
||||
Cloudflare D1 的 schema migration 同種子資料。
|
||||
Cloudflare D1 的 schema migration SQL。
|
||||
|
||||
## Ownership
|
||||
|
||||
- 擁有 `migrations/` 全部 SQL、`migrations/meta/` 同 `seed.sql`。
|
||||
- 擁有 `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` 表。
|
||||
- **`seed.sql` 係手寫、獨立於 migration**:全部用 `INSERT OR REPLACE`,可重複執行。`db:migrate` **唔會**執行 seed。
|
||||
- **`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` — 匯入種子
|
||||
- **Seed 內容**:公司資料(`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` 仍係佔位,部署前要填)。
|
||||
- `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 → 直接 `db:seed:local`。
|
||||
- 改 schema → 先 `db:generate`,再 `db:migrate:local`;改 seed → 直接改 `scripts/seed.sql` 再 `db:seed:local`。
|
||||
- 新增 setting key 時同步更新 `src/data/settings-fields.ts`。
|
||||
|
||||
## Verification
|
||||
|
||||
Reference in New Issue
Block a user