- 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)
61 lines
3.7 KiB
TypeScript
61 lines
3.7 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_users_interest" AS ENUM('الوكلاء', 'RAG', 'الأتمتة', 'النماذج المفتوحة');
|
|
CREATE TYPE "public"."enum_users_level" AS ENUM('مبتدئ', 'متوسط', 'متقدم');
|
|
CREATE TYPE "public"."enum_users_goal" AS ENUM('بناء مشروع ذكاء اصطناعي', 'تطوير مساري المهني', 'أتمتة العمل', 'فهم الوكلاء بعمق');
|
|
CREATE TYPE "public"."enum_posts_level" AS ENUM('مبتدئ', 'متوسط', 'متقدم');
|
|
CREATE TABLE "post_likes" (
|
|
"id" serial PRIMARY KEY NOT NULL,
|
|
"user_id" integer NOT NULL,
|
|
"post_id" integer NOT NULL,
|
|
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
|
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
ALTER TABLE "users" ADD COLUMN "interest" "enum_users_interest";
|
|
ALTER TABLE "users" ADD COLUMN "level" "enum_users_level";
|
|
ALTER TABLE "users" ADD COLUMN "goal" "enum_users_goal";
|
|
ALTER TABLE "users" ADD COLUMN "prefs" jsonb;
|
|
ALTER TABLE "users" ADD COLUMN "email_verified" boolean DEFAULT false;
|
|
ALTER TABLE "users" ADD COLUMN "verification_token" varchar;
|
|
ALTER TABLE "users" ADD COLUMN "onboarded" boolean DEFAULT false;
|
|
ALTER TABLE "posts" ADD COLUMN "level" "enum_posts_level" DEFAULT 'مبتدئ' NOT NULL;
|
|
ALTER TABLE "posts" ADD COLUMN "views" numeric DEFAULT 0;
|
|
ALTER TABLE "posts" ADD COLUMN "likes" numeric DEFAULT 0;
|
|
ALTER TABLE "payload_locked_documents_rels" ADD COLUMN "post_likes_id" integer;
|
|
ALTER TABLE "post_likes" ADD CONSTRAINT "post_likes_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;
|
|
ALTER TABLE "post_likes" ADD CONSTRAINT "post_likes_post_id_posts_id_fk" FOREIGN KEY ("post_id") REFERENCES "public"."posts"("id") ON DELETE set null ON UPDATE no action;
|
|
CREATE INDEX "post_likes_user_idx" ON "post_likes" USING btree ("user_id");
|
|
CREATE INDEX "post_likes_post_idx" ON "post_likes" USING btree ("post_id");
|
|
CREATE INDEX "post_likes_updated_at_idx" ON "post_likes" USING btree ("updated_at");
|
|
CREATE INDEX "post_likes_created_at_idx" ON "post_likes" USING btree ("created_at");
|
|
ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_post_likes_fk" FOREIGN KEY ("post_likes_id") REFERENCES "public"."post_likes"("id") ON DELETE cascade ON UPDATE no action;
|
|
CREATE INDEX "payload_locked_documents_rels_post_likes_id_idx" ON "payload_locked_documents_rels" USING btree ("post_likes_id");`)
|
|
}
|
|
|
|
export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
|
|
await db.execute(sql`
|
|
ALTER TABLE "post_likes" DISABLE ROW LEVEL SECURITY;
|
|
DROP TABLE "post_likes" CASCADE;
|
|
ALTER TABLE "payload_locked_documents_rels" DROP CONSTRAINT "payload_locked_documents_rels_post_likes_fk";
|
|
|
|
DROP INDEX "payload_locked_documents_rels_post_likes_id_idx";
|
|
ALTER TABLE "users" DROP COLUMN "interest";
|
|
ALTER TABLE "users" DROP COLUMN "level";
|
|
ALTER TABLE "users" DROP COLUMN "goal";
|
|
ALTER TABLE "users" DROP COLUMN "prefs";
|
|
ALTER TABLE "users" DROP COLUMN "email_verified";
|
|
ALTER TABLE "users" DROP COLUMN "verification_token";
|
|
ALTER TABLE "users" DROP COLUMN "onboarded";
|
|
ALTER TABLE "posts" DROP COLUMN "level";
|
|
ALTER TABLE "posts" DROP COLUMN "views";
|
|
ALTER TABLE "posts" DROP COLUMN "likes";
|
|
ALTER TABLE "payload_locked_documents_rels" DROP COLUMN "post_likes_id";
|
|
DROP TYPE "public"."enum_users_interest";
|
|
DROP TYPE "public"."enum_users_level";
|
|
DROP TYPE "public"."enum_users_goal";
|
|
DROP TYPE "public"."enum_posts_level";`)
|
|
}
|