fix: cleanup unused collections

This commit is contained in:
Benno Tielen 2025-02-24 09:44:24 +01:00
parent ca69b9a606
commit 010134a626
11 changed files with 5847 additions and 200 deletions

View file

@ -2,16 +2,18 @@ import type { CollectionConfig } from 'payload'
export const Documents: CollectionConfig = { export const Documents: CollectionConfig = {
slug: 'documents', slug: 'documents',
labels: {
plural: {
de: "PDF-Dokumenten"
},
singular: {
de: "PDF-Dokument"
}
},
access: { access: {
read: () => true, read: () => true,
}, },
fields: [ fields: [],
{
name: 'name',
type: 'text',
required: true
}
],
upload: { upload: {
mimeTypes: ['application/pdf'] mimeTypes: ['application/pdf']
}, },

View file

@ -111,8 +111,9 @@ export const Events: CollectionConfig = {
type: 'textarea', type: 'textarea',
required: true, required: true,
label: { label: {
de: 'Kurzumschreibung', de: 'Kurzumschreibung (max. 200)',
}, },
maxLength: 200
}, },
{ {
name: 'description', name: 'description',

View file

@ -1,4 +1,5 @@
import type { CollectionConfig } from 'payload' import type { CollectionConfig } from 'payload'
import { Media as MediaType } from '../payload-types'
export const Media: CollectionConfig = { export const Media: CollectionConfig = {
slug: 'media', slug: 'media',
@ -8,6 +9,14 @@ export const Media: CollectionConfig = {
admin: { admin: {
listSearchableFields: ['search'] listSearchableFields: ['search']
}, },
labels: {
singular: {
de: "Bild"
},
plural: {
de: "Bilder"
}
},
fields: [ fields: [
{ {
name: 'alt', name: 'alt',

View file

@ -41,15 +41,6 @@ export const Parish: CollectionConfig = {
allowCreate: false, allowCreate: false,
}, },
}, },
{
name: 'employees',
label: {
de: 'Mitarbeiter',
},
type: 'relationship',
relationTo: 'employees',
hasMany: true,
},
{ {
name: 'contactPersons', name: 'contactPersons',
label: { label: {

View file

@ -6,6 +6,14 @@ export const Users: CollectionConfig = {
admin: { admin: {
useAsTitle: 'email', useAsTitle: 'email',
}, },
labels: {
singular: {
de: "Benutzerkonto"
},
plural: {
de: "Benutzerkonten"
}
},
auth: true, auth: true,
fields: [ fields: [
{ {

View file

@ -22,6 +22,8 @@ export const Worship: CollectionConfig = {
admin: { admin: {
date: { date: {
pickerAppearance: 'dayAndTime', pickerAppearance: 'dayAndTime',
timeIntervals: 15,
timeFormat: 'HH:mm'
}, },
}, },
}, },

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,180 @@
import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'
export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
await db.execute(sql`
ALTER TABLE "employees" DISABLE ROW LEVEL SECURITY;
ALTER TABLE "testimony" DISABLE ROW LEVEL SECURITY;
ALTER TABLE "page_blocks_content" DISABLE ROW LEVEL SECURITY;
ALTER TABLE "page_blocks_title" DISABLE ROW LEVEL SECURITY;
ALTER TABLE "page_blocks_testimony" DISABLE ROW LEVEL SECURITY;
ALTER TABLE "page" DISABLE ROW LEVEL SECURITY;
DROP TABLE "employees" CASCADE;
DROP TABLE "testimony" CASCADE;
DROP TABLE "page_blocks_content" CASCADE;
DROP TABLE "page_blocks_title" CASCADE;
DROP TABLE "page_blocks_testimony" CASCADE;
DROP TABLE "page" CASCADE;
ALTER TABLE "parish_rels" DROP CONSTRAINT IF EXISTS "parish_rels_employees_fk";
ALTER TABLE "payload_locked_documents_rels" DROP CONSTRAINT IF EXISTS "payload_locked_documents_rels_employees_fk";
ALTER TABLE "payload_locked_documents_rels" DROP CONSTRAINT IF EXISTS "payload_locked_documents_rels_testimony_fk";
ALTER TABLE "payload_locked_documents_rels" DROP CONSTRAINT IF EXISTS "payload_locked_documents_rels_page_fk";
DROP INDEX IF EXISTS "parish_rels_employees_id_idx";
DROP INDEX IF EXISTS "payload_locked_documents_rels_employees_id_idx";
DROP INDEX IF EXISTS "payload_locked_documents_rels_testimony_id_idx";
DROP INDEX IF EXISTS "payload_locked_documents_rels_page_id_idx";
ALTER TABLE "announcement" ALTER COLUMN "date" SET DEFAULT '2025-03-02T08:36:52.653Z';
ALTER TABLE "calendar" ALTER COLUMN "date" SET DEFAULT '2025-03-02T08:36:52.738Z';
ALTER TABLE "parish_rels" DROP COLUMN IF EXISTS "employees_id";
ALTER TABLE "documents" DROP COLUMN IF EXISTS "name";
ALTER TABLE "payload_locked_documents_rels" DROP COLUMN IF EXISTS "employees_id";
ALTER TABLE "payload_locked_documents_rels" DROP COLUMN IF EXISTS "testimony_id";
ALTER TABLE "payload_locked_documents_rels" DROP COLUMN IF EXISTS "page_id";
DROP TYPE "public"."enum_testimony_category";`)
}
export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
await db.execute(sql`
CREATE TYPE "public"."enum_testimony_category" AS ENUM('EUCHARIST');
CREATE TABLE IF NOT EXISTS "employees" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"photo_id" uuid,
"name" varchar NOT NULL,
"occupation" varchar NOT NULL,
"email" varchar,
"telephone" varchar,
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL
);
CREATE TABLE IF NOT EXISTS "testimony" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"testimony" varchar NOT NULL,
"name" varchar NOT NULL,
"occupation" varchar,
"category" "enum_testimony_category" NOT NULL,
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL
);
CREATE TABLE IF NOT EXISTS "page_blocks_content" (
"_order" integer NOT NULL,
"_parent_id" uuid NOT NULL,
"_path" text NOT NULL,
"id" varchar PRIMARY KEY NOT NULL,
"content" jsonb NOT NULL,
"block_name" varchar
);
CREATE TABLE IF NOT EXISTS "page_blocks_title" (
"_order" integer NOT NULL,
"_parent_id" uuid NOT NULL,
"_path" text NOT NULL,
"id" varchar PRIMARY KEY NOT NULL,
"title" varchar NOT NULL,
"block_name" varchar
);
CREATE TABLE IF NOT EXISTS "page_blocks_testimony" (
"_order" integer NOT NULL,
"_parent_id" uuid NOT NULL,
"_path" text NOT NULL,
"id" varchar PRIMARY KEY NOT NULL,
"testimony_id" uuid NOT NULL,
"block_name" varchar
);
CREATE TABLE IF NOT EXISTS "page" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"title" varchar NOT NULL,
"slug" varchar 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 "announcement" ALTER COLUMN "date" SET DEFAULT '2025-02-09T10:47:41.631Z';
ALTER TABLE "calendar" ALTER COLUMN "date" SET DEFAULT '2025-02-09T10:47:41.722Z';
ALTER TABLE "parish_rels" ADD COLUMN "employees_id" uuid;
ALTER TABLE "documents" ADD COLUMN "name" varchar NOT NULL;
ALTER TABLE "payload_locked_documents_rels" ADD COLUMN "employees_id" uuid;
ALTER TABLE "payload_locked_documents_rels" ADD COLUMN "testimony_id" uuid;
ALTER TABLE "payload_locked_documents_rels" ADD COLUMN "page_id" uuid;
DO $$ BEGIN
ALTER TABLE "employees" ADD CONSTRAINT "employees_photo_id_media_id_fk" FOREIGN KEY ("photo_id") REFERENCES "public"."media"("id") ON DELETE set null ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
DO $$ BEGIN
ALTER TABLE "page_blocks_content" ADD CONSTRAINT "page_blocks_content_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."page"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
DO $$ BEGIN
ALTER TABLE "page_blocks_title" ADD CONSTRAINT "page_blocks_title_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."page"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
DO $$ BEGIN
ALTER TABLE "page_blocks_testimony" ADD CONSTRAINT "page_blocks_testimony_testimony_id_testimony_id_fk" FOREIGN KEY ("testimony_id") REFERENCES "public"."testimony"("id") ON DELETE set null ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
DO $$ BEGIN
ALTER TABLE "page_blocks_testimony" ADD CONSTRAINT "page_blocks_testimony_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."page"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
CREATE INDEX IF NOT EXISTS "employees_photo_idx" ON "employees" USING btree ("photo_id");
CREATE INDEX IF NOT EXISTS "employees_updated_at_idx" ON "employees" USING btree ("updated_at");
CREATE INDEX IF NOT EXISTS "employees_created_at_idx" ON "employees" USING btree ("created_at");
CREATE INDEX IF NOT EXISTS "testimony_updated_at_idx" ON "testimony" USING btree ("updated_at");
CREATE INDEX IF NOT EXISTS "testimony_created_at_idx" ON "testimony" USING btree ("created_at");
CREATE INDEX IF NOT EXISTS "page_blocks_content_order_idx" ON "page_blocks_content" USING btree ("_order");
CREATE INDEX IF NOT EXISTS "page_blocks_content_parent_id_idx" ON "page_blocks_content" USING btree ("_parent_id");
CREATE INDEX IF NOT EXISTS "page_blocks_content_path_idx" ON "page_blocks_content" USING btree ("_path");
CREATE INDEX IF NOT EXISTS "page_blocks_title_order_idx" ON "page_blocks_title" USING btree ("_order");
CREATE INDEX IF NOT EXISTS "page_blocks_title_parent_id_idx" ON "page_blocks_title" USING btree ("_parent_id");
CREATE INDEX IF NOT EXISTS "page_blocks_title_path_idx" ON "page_blocks_title" USING btree ("_path");
CREATE INDEX IF NOT EXISTS "page_blocks_testimony_order_idx" ON "page_blocks_testimony" USING btree ("_order");
CREATE INDEX IF NOT EXISTS "page_blocks_testimony_parent_id_idx" ON "page_blocks_testimony" USING btree ("_parent_id");
CREATE INDEX IF NOT EXISTS "page_blocks_testimony_path_idx" ON "page_blocks_testimony" USING btree ("_path");
CREATE INDEX IF NOT EXISTS "page_blocks_testimony_testimony_idx" ON "page_blocks_testimony" USING btree ("testimony_id");
CREATE INDEX IF NOT EXISTS "page_updated_at_idx" ON "page" USING btree ("updated_at");
CREATE INDEX IF NOT EXISTS "page_created_at_idx" ON "page" USING btree ("created_at");
DO $$ BEGIN
ALTER TABLE "parish_rels" ADD CONSTRAINT "parish_rels_employees_fk" FOREIGN KEY ("employees_id") REFERENCES "public"."employees"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
DO $$ BEGIN
ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_employees_fk" FOREIGN KEY ("employees_id") REFERENCES "public"."employees"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
DO $$ BEGIN
ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_testimony_fk" FOREIGN KEY ("testimony_id") REFERENCES "public"."testimony"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
DO $$ BEGIN
ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_page_fk" FOREIGN KEY ("page_id") REFERENCES "public"."page"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
CREATE INDEX IF NOT EXISTS "parish_rels_employees_id_idx" ON "parish_rels" USING btree ("employees_id");
CREATE INDEX IF NOT EXISTS "payload_locked_documents_rels_employees_id_idx" ON "payload_locked_documents_rels" USING btree ("employees_id");
CREATE INDEX IF NOT EXISTS "payload_locked_documents_rels_testimony_id_idx" ON "payload_locked_documents_rels" USING btree ("testimony_id");
CREATE INDEX IF NOT EXISTS "payload_locked_documents_rels_page_id_idx" ON "payload_locked_documents_rels" USING btree ("page_id");`)
}

View file

@ -3,6 +3,7 @@ import * as migration_20241217_135114_contact_person_photo from './20241217_1351
import * as migration_20250128_100809_pope_prayer_intentions from './20250128_100809_pope_prayer_intentions'; import * as migration_20250128_100809_pope_prayer_intentions from './20250128_100809_pope_prayer_intentions';
import * as migration_20250128_145145_liturgical_calendar from './20250128_145145_liturgical_calendar'; import * as migration_20250128_145145_liturgical_calendar from './20250128_145145_liturgical_calendar';
import * as migration_20250202_104742 from './20250202_104742'; import * as migration_20250202_104742 from './20250202_104742';
import * as migration_20250224_083653_cleanup from './20250224_083653_cleanup';
export const migrations = [ export const migrations = [
{ {
@ -28,6 +29,11 @@ export const migrations = [
{ {
up: migration_20250202_104742.up, up: migration_20250202_104742.up,
down: migration_20250202_104742.down, down: migration_20250202_104742.down,
name: '20250202_104742' name: '20250202_104742',
},
{
up: migration_20250224_083653_cleanup.up,
down: migration_20250224_083653_cleanup.down,
name: '20250224_083653_cleanup'
}, },
]; ];

View file

@ -23,12 +23,9 @@ export interface Config {
contactPerson: ContactPerson; contactPerson: ContactPerson;
locations: Location; locations: Location;
group: Group; group: Group;
employees: Employee;
testimony: Testimony;
page: Page;
users: User;
documents: Document; documents: Document;
media: Media; media: Media;
users: User;
'payload-locked-documents': PayloadLockedDocument; 'payload-locked-documents': PayloadLockedDocument;
'payload-preferences': PayloadPreference; 'payload-preferences': PayloadPreference;
'payload-migrations': PayloadMigration; 'payload-migrations': PayloadMigration;
@ -47,12 +44,9 @@ export interface Config {
contactPerson: ContactPersonSelect<false> | ContactPersonSelect<true>; contactPerson: ContactPersonSelect<false> | ContactPersonSelect<true>;
locations: LocationsSelect<false> | LocationsSelect<true>; locations: LocationsSelect<false> | LocationsSelect<true>;
group: GroupSelect<false> | GroupSelect<true>; group: GroupSelect<false> | GroupSelect<true>;
employees: EmployeesSelect<false> | EmployeesSelect<true>;
testimony: TestimonySelect<false> | TestimonySelect<true>;
page: PageSelect<false> | PageSelect<true>;
users: UsersSelect<false> | UsersSelect<true>;
documents: DocumentsSelect<false> | DocumentsSelect<true>; documents: DocumentsSelect<false> | DocumentsSelect<true>;
media: MediaSelect<false> | MediaSelect<true>; media: MediaSelect<false> | MediaSelect<true>;
users: UsersSelect<false> | UsersSelect<true>;
'payload-locked-documents': PayloadLockedDocumentsSelect<false> | PayloadLockedDocumentsSelect<true>; 'payload-locked-documents': PayloadLockedDocumentsSelect<false> | PayloadLockedDocumentsSelect<true>;
'payload-preferences': PayloadPreferencesSelect<false> | PayloadPreferencesSelect<true>; 'payload-preferences': PayloadPreferencesSelect<false> | PayloadPreferencesSelect<true>;
'payload-migrations': PayloadMigrationsSelect<false> | PayloadMigrationsSelect<true>; 'payload-migrations': PayloadMigrationsSelect<false> | PayloadMigrationsSelect<true>;
@ -98,7 +92,6 @@ export interface Parish {
name: string; name: string;
slug: string; slug: string;
churches: (string | Church)[]; churches: (string | Church)[];
employees?: (string | Employee)[] | null;
contactPersons?: contactPersons?:
| { | {
title: string; title: string;
@ -130,20 +123,6 @@ export interface Church {
updatedAt: string; updatedAt: string;
createdAt: string; createdAt: string;
} }
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "employees".
*/
export interface Employee {
id: string;
photo?: (string | null) | Media;
name: string;
occupation: string;
email?: string | null;
telephone?: string | null;
updatedAt: string;
createdAt: string;
}
/** /**
* This interface was referenced by `Config`'s JSON-Schema * This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "media". * via the `definition` "media".
@ -247,7 +226,6 @@ export interface Announcement {
*/ */
export interface Document { export interface Document {
id: string; id: string;
name: string;
prefix?: string | null; prefix?: string | null;
updatedAt: string; updatedAt: string;
createdAt: string; createdAt: string;
@ -492,64 +470,6 @@ export interface ContactPerson {
updatedAt: string; updatedAt: string;
createdAt: string; createdAt: string;
} }
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "testimony".
*/
export interface Testimony {
id: string;
testimony: string;
name: string;
occupation?: string | null;
category: 'EUCHARIST';
updatedAt: string;
createdAt: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "page".
*/
export interface Page {
id: string;
title: string;
slug: string;
content: (
| {
content: {
root: {
type: string;
children: {
type: string;
version: number;
[k: string]: unknown;
}[];
direction: ('ltr' | 'rtl') | null;
format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | '';
indent: number;
version: number;
};
[k: string]: unknown;
};
id?: string | null;
blockName?: string | null;
blockType: 'content';
}
| {
title: string;
id?: string | null;
blockName?: string | null;
blockType: 'title';
}
| {
testimony: string | Testimony;
id?: string | null;
blockName?: string | null;
blockType: 'testimony';
}
)[];
updatedAt: string;
createdAt: string;
}
/** /**
* This interface was referenced by `Config`'s JSON-Schema * This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "users". * via the `definition` "users".
@ -625,22 +545,6 @@ export interface PayloadLockedDocument {
relationTo: 'group'; relationTo: 'group';
value: string | Group; value: string | Group;
} | null) } | null)
| ({
relationTo: 'employees';
value: string | Employee;
} | null)
| ({
relationTo: 'testimony';
value: string | Testimony;
} | null)
| ({
relationTo: 'page';
value: string | Page;
} | null)
| ({
relationTo: 'users';
value: string | User;
} | null)
| ({ | ({
relationTo: 'documents'; relationTo: 'documents';
value: string | Document; value: string | Document;
@ -648,6 +552,10 @@ export interface PayloadLockedDocument {
| ({ | ({
relationTo: 'media'; relationTo: 'media';
value: string | Media; value: string | Media;
} | null)
| ({
relationTo: 'users';
value: string | User;
} | null); } | null);
globalSlug?: string | null; globalSlug?: string | null;
user: { user: {
@ -699,7 +607,6 @@ export interface ParishSelect<T extends boolean = true> {
name?: T; name?: T;
slug?: T; slug?: T;
churches?: T; churches?: T;
employees?: T;
contactPersons?: contactPersons?:
| T | T
| { | {
@ -949,90 +856,11 @@ export interface GroupSelect<T extends boolean = true> {
updatedAt?: T; updatedAt?: T;
createdAt?: T; createdAt?: T;
} }
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "employees_select".
*/
export interface EmployeesSelect<T extends boolean = true> {
photo?: T;
name?: T;
occupation?: T;
email?: T;
telephone?: T;
updatedAt?: T;
createdAt?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "testimony_select".
*/
export interface TestimonySelect<T extends boolean = true> {
testimony?: T;
name?: T;
occupation?: T;
category?: T;
updatedAt?: T;
createdAt?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "page_select".
*/
export interface PageSelect<T extends boolean = true> {
title?: T;
slug?: T;
content?:
| T
| {
content?:
| T
| {
content?: T;
id?: T;
blockName?: T;
};
title?:
| T
| {
title?: T;
id?: T;
blockName?: T;
};
testimony?:
| T
| {
testimony?: T;
id?: T;
blockName?: T;
};
};
updatedAt?: T;
createdAt?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "users_select".
*/
export interface UsersSelect<T extends boolean = true> {
name?: T;
roles?: T;
groups?: T;
updatedAt?: T;
createdAt?: T;
email?: T;
resetPasswordToken?: T;
resetPasswordExpiration?: T;
salt?: T;
hash?: T;
loginAttempts?: T;
lockUntil?: T;
}
/** /**
* This interface was referenced by `Config`'s JSON-Schema * This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "documents_select". * via the `definition` "documents_select".
*/ */
export interface DocumentsSelect<T extends boolean = true> { export interface DocumentsSelect<T extends boolean = true> {
name?: T;
prefix?: T; prefix?: T;
updatedAt?: T; updatedAt?: T;
createdAt?: T; createdAt?: T;
@ -1110,6 +938,24 @@ export interface MediaSelect<T extends boolean = true> {
}; };
}; };
} }
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "users_select".
*/
export interface UsersSelect<T extends boolean = true> {
name?: T;
roles?: T;
groups?: T;
updatedAt?: T;
createdAt?: T;
email?: T;
resetPasswordToken?: T;
resetPasswordExpiration?: T;
salt?: T;
hash?: T;
loginAttempts?: T;
lockUntil?: T;
}
/** /**
* This interface was referenced by `Config`'s JSON-Schema * This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "payload-locked-documents_select". * via the `definition` "payload-locked-documents_select".

View file

@ -59,12 +59,9 @@ export default buildConfig({
ContactPerson, ContactPerson,
Locations, Locations,
Groups, Groups,
Employees,
Testimony,
Pages,
Users,
Documents, Documents,
Media, Media,
Users,
], ],
editor: lexicalEditor( editor: lexicalEditor(
{ {