2026-09-02 16:17:01 +01:00
|
|
|
import path from 'path';
|
|
|
|
|
import { fileURLToPath } from 'url';
|
|
|
|
|
import { buildConfig } from 'payload';
|
|
|
|
|
import { postgresAdapter } from '@payloadcms/db-postgres';
|
|
|
|
|
import { lexicalEditor } from '@payloadcms/richtext-lexical';
|
|
|
|
|
import sharp from 'sharp';
|
|
|
|
|
import { Users } from '@/collections/Users';
|
2026-09-02 16:24:15 +01:00
|
|
|
import { Posts } from '@/collections/Posts';
|
|
|
|
|
import { Media } from '@/collections/Media';
|
2026-09-02 16:17:01 +01:00
|
|
|
import { PAYLOAD_API_ROUTE, PAYLOAD_ADMIN_ROUTE } from '@/lib/payloadRoutes';
|
2026-09-02 18:31:38 +01:00
|
|
|
import { migrations } from '@/migrations';
|
2026-09-02 16:17:01 +01:00
|
|
|
|
|
|
|
|
const filename = fileURLToPath(import.meta.url);
|
|
|
|
|
const dirname = path.dirname(filename);
|
|
|
|
|
|
|
|
|
|
export default buildConfig({
|
|
|
|
|
admin: { user: Users.slug },
|
|
|
|
|
// Defined in lib/payloadRoutes.ts, which carries the reasoning and is what
|
|
|
|
|
// the test asserts. Never inline these — /api belongs to the FastAPI proxy.
|
|
|
|
|
routes: { api: PAYLOAD_API_ROUTE, admin: PAYLOAD_ADMIN_ROUTE },
|
2026-09-02 16:24:15 +01:00
|
|
|
collections: [Users, Posts, Media],
|
2026-09-02 16:17:01 +01:00
|
|
|
editor: lexicalEditor(),
|
|
|
|
|
secret: process.env.PAYLOAD_SECRET || '',
|
|
|
|
|
typescript: { outputFile: path.resolve(dirname, 'payload-types.ts') },
|
|
|
|
|
db: postgresAdapter({
|
|
|
|
|
pool: { connectionString: process.env.DATABASE_URL },
|
2026-09-14 23:01:22 +01:00
|
|
|
// Its own schema separates blog content from pipeline-managed school
|
|
|
|
|
// tables and Airflow metadata. The schema is created by the initial
|
2026-09-02 18:31:38 +01:00
|
|
|
// migration: schemaName says where tables go, it does not create anything.
|
|
|
|
|
//
|
|
|
|
|
// prodMigrations runs pending migrations during server init. Without it a
|
|
|
|
|
// production container connects to an empty schema and fails its first
|
|
|
|
|
// query with 42P01 — the adapter cannot self-create tables, because
|
|
|
|
|
// db-postgres/connect.js gates push on NODE_ENV !== 'production'.
|
2026-09-02 16:17:01 +01:00
|
|
|
schemaName: 'payload',
|
2026-09-02 18:31:38 +01:00
|
|
|
prodMigrations: migrations,
|
2026-09-02 16:17:01 +01:00
|
|
|
}),
|
|
|
|
|
sharp,
|
|
|
|
|
});
|