Files
anwar-pi-website/web/src/migrations/20261010_142214.ts
T
AHMED 0161924088 Free early-access launch: LAUNCH_MODE policy, CRO, pipeline hardening, AI-SEO, ops
- launch.ts policy: LAUNCH_MODE=free_early_access default; effective access =
  published && (free || early); intended tier (access) never rewritten
- Billing off server-side: /api/subscribe 503 honest copy; subscribe CTAs
  render disabled 'قريباً' from first paint; /subscription early-access panel
  + /api/notify (LaunchNotifications) with honest 503 when mail transport off
- Signup trust: verification email at signup (Users afterChange), no
  confirm-password, 429 message fidelity, typo suggestion, live password hint
- Agent pipeline: pickFields strips access/readingMinutes, sourceId dedup,
  secret-scan 422 (pattern names only), string-content rejected (was silently
  replaced), publish stays explicit opt-in
- lexical.ts: root unwrap fix — lexicalToText/countLexicalWords returned 0
  for real serialized trees (secret scan + readingMinutes were inert)
- llms-full.txt: fetchIndexDocs(true) — bodies were never selected
- Content honesty: contentType/authorName/sourceId fields + migration,
  readingMinutes computed at write (160 wpm) + backfill script, byline,
  'حُدّث' freshness
- SEO/AI-SEO: metadata rewrite (published-only, og:image 1200x630), Article +
  BreadcrumbList + FAQPage + Organization JSON-LD, isAccessibleForFree honest,
  table renderer, robots AI-crawler policy (10 named bots), llms.txt +
  llms-full.txt, /topics/* hubs + sitemap, noindex auth pages, www 301
- Ops: backup-db.sh (restore rehearsed on VPS), docs copies (launch
  readiness + marketing audit + owner-inputs for L-03), GLOSSARY.md entries

Verified: tsc --noEmit 0, npm run build 0, local smoke (ghost VIP read,
subscribe/notify/agent APIs, signup token, 429 on 6th, llms/topics/sitemap,
og:image/JSON-LD)
2026-10-10 18:03:45 +03:00

42 lines
2.5 KiB
TypeScript

import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'
export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
await db.execute(sql`
CREATE TYPE "public"."enum_posts_content_type" AS ENUM('note', 'tutorial', 'case_study', 'comparison');
CREATE TYPE "public"."enum_launch_notifications_source" AS ENUM('subscription');
CREATE TABLE "launch_notifications" (
"id" serial PRIMARY KEY NOT NULL,
"email" varchar NOT NULL,
"source" "enum_launch_notifications_source" DEFAULT 'subscription',
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL
);
ALTER TABLE "posts" ADD COLUMN "content_type" "enum_posts_content_type";
ALTER TABLE "posts" ADD COLUMN "author_name" varchar;
ALTER TABLE "posts" ADD COLUMN "source_id" varchar;
ALTER TABLE "payload_locked_documents_rels" ADD COLUMN "launch_notifications_id" integer;
CREATE UNIQUE INDEX "launch_notifications_email_idx" ON "launch_notifications" USING btree ("email");
CREATE INDEX "launch_notifications_updated_at_idx" ON "launch_notifications" USING btree ("updated_at");
CREATE INDEX "launch_notifications_created_at_idx" ON "launch_notifications" USING btree ("created_at");
ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_launch_notifications_fk" FOREIGN KEY ("launch_notifications_id") REFERENCES "public"."launch_notifications"("id") ON DELETE cascade ON UPDATE no action;
CREATE INDEX "posts_source_id_idx" ON "posts" USING btree ("source_id");
CREATE INDEX "payload_locked_documents_rels_launch_notifications_id_idx" ON "payload_locked_documents_rels" USING btree ("launch_notifications_id");`)
}
export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
await db.execute(sql`
ALTER TABLE "launch_notifications" DISABLE ROW LEVEL SECURITY;
DROP TABLE "launch_notifications" CASCADE;
ALTER TABLE "payload_locked_documents_rels" DROP CONSTRAINT "payload_locked_documents_rels_launch_notifications_fk";
DROP INDEX "posts_source_id_idx";
DROP INDEX "payload_locked_documents_rels_launch_notifications_id_idx";
ALTER TABLE "posts" DROP COLUMN "content_type";
ALTER TABLE "posts" DROP COLUMN "author_name";
ALTER TABLE "posts" DROP COLUMN "source_id";
ALTER TABLE "payload_locked_documents_rels" DROP COLUMN "launch_notifications_id";
DROP TYPE "public"."enum_posts_content_type";
DROP TYPE "public"."enum_launch_notifications_source";`)
}