/* tslint:disable */
/* eslint-disable */
/**
 * This file was automatically generated by Payload.
 * DO NOT MODIFY IT BY HAND. Instead, modify your source Payload config,
 * and re-run `payload generate:db-schema` to regenerate this file.
 */

import type {} from '@payloadcms/db-postgres';
import {
  pgTable,
  index,
  uniqueIndex,
  foreignKey,
  integer,
  varchar,
  timestamp,
  serial,
  numeric,
  jsonb,
  boolean,
  pgEnum,
} from '@payloadcms/db-postgres/drizzle/pg-core';
import { sql, relations } from '@payloadcms/db-postgres/drizzle';
export const enum__locales = pgEnum('enum__locales', ['de', 'en']);
export const enum_posts_status = pgEnum('enum_posts_status', ['draft', 'published']);
export const enum__posts_v_version_status = pgEnum('enum__posts_v_version_status', [
  'draft',
  'published',
]);
export const enum__posts_v_published_locale = pgEnum('enum__posts_v_published_locale', [
  'de',
  'en',
]);
export const enum_form_submissions_type = pgEnum('enum_form_submissions_type', [
  'contact',
  'product_quote',
]);
export const enum_products_status = pgEnum('enum_products_status', ['draft', 'published']);
export const enum__products_v_version_status = pgEnum('enum__products_v_version_status', [
  'draft',
  'published',
]);
export const enum__products_v_published_locale = pgEnum('enum__products_v_published_locale', [
  'de',
  'en',
]);
export const enum_pages_layout = pgEnum('enum_pages_layout', ['default', 'fullBleed']);
export const enum_pages_status = pgEnum('enum_pages_status', ['draft', 'published']);
export const enum__pages_v_version_layout = pgEnum('enum__pages_v_version_layout', [
  'default',
  'fullBleed',
]);
export const enum__pages_v_version_status = pgEnum('enum__pages_v_version_status', [
  'draft',
  'published',
]);
export const enum__pages_v_published_locale = pgEnum('enum__pages_v_published_locale', [
  'de',
  'en',
]);

export const users_sessions = pgTable(
  'users_sessions',
  {
    _order: integer('_order').notNull(),
    _parentID: integer('_parent_id').notNull(),
    id: varchar('id').primaryKey(),
    createdAt: timestamp('created_at', { mode: 'string', withTimezone: true, precision: 3 }),
    expiresAt: timestamp('expires_at', {
      mode: 'string',
      withTimezone: true,
      precision: 3,
    }).notNull(),
  },
  (columns) => [
    index('users_sessions_order_idx').on(columns._order),
    index('users_sessions_parent_id_idx').on(columns._parentID),
    foreignKey({
      columns: [columns['_parentID']],
      foreignColumns: [users.id],
      name: 'users_sessions_parent_id_fk',
    }).onDelete('cascade'),
  ],
);

export const users = pgTable(
  'users',
  {
    id: serial('id').primaryKey(),
    updatedAt: timestamp('updated_at', { mode: 'string', withTimezone: true, precision: 3 })
      .defaultNow()
      .notNull(),
    createdAt: timestamp('created_at', { mode: 'string', withTimezone: true, precision: 3 })
      .defaultNow()
      .notNull(),
    email: varchar('email').notNull(),
    resetPasswordToken: varchar('reset_password_token'),
    resetPasswordExpiration: timestamp('reset_password_expiration', {
      mode: 'string',
      withTimezone: true,
      precision: 3,
    }),
    salt: varchar('salt'),
    hash: varchar('hash'),
    loginAttempts: numeric('login_attempts', { mode: 'number' }).default(0),
    lockUntil: timestamp('lock_until', { mode: 'string', withTimezone: true, precision: 3 }),
  },
  (columns) => [
    index('users_updated_at_idx').on(columns.updatedAt),
    index('users_created_at_idx').on(columns.createdAt),
    uniqueIndex('users_email_idx').on(columns.email),
  ],
);

export const media = pgTable(
  'media',
  {
    id: serial('id').primaryKey(),
    alt: varchar('alt').notNull(),
    caption: varchar('caption'),
    updatedAt: timestamp('updated_at', { mode: 'string', withTimezone: true, precision: 3 })
      .defaultNow()
      .notNull(),
    createdAt: timestamp('created_at', { mode: 'string', withTimezone: true, precision: 3 })
      .defaultNow()
      .notNull(),
    url: varchar('url'),
    thumbnailURL: varchar('thumbnail_u_r_l'),
    filename: varchar('filename'),
    mimeType: varchar('mime_type'),
    filesize: numeric('filesize', { mode: 'number' }),
    width: numeric('width', { mode: 'number' }),
    height: numeric('height', { mode: 'number' }),
    focalX: numeric('focal_x', { mode: 'number' }),
    focalY: numeric('focal_y', { mode: 'number' }),
    sizes_thumbnail_url: varchar('sizes_thumbnail_url'),
    sizes_thumbnail_width: numeric('sizes_thumbnail_width', { mode: 'number' }),
    sizes_thumbnail_height: numeric('sizes_thumbnail_height', { mode: 'number' }),
    sizes_thumbnail_mimeType: varchar('sizes_thumbnail_mime_type'),
    sizes_thumbnail_filesize: numeric('sizes_thumbnail_filesize', { mode: 'number' }),
    sizes_thumbnail_filename: varchar('sizes_thumbnail_filename'),
    sizes_card_url: varchar('sizes_card_url'),
    sizes_card_width: numeric('sizes_card_width', { mode: 'number' }),
    sizes_card_height: numeric('sizes_card_height', { mode: 'number' }),
    sizes_card_mimeType: varchar('sizes_card_mime_type'),
    sizes_card_filesize: numeric('sizes_card_filesize', { mode: 'number' }),
    sizes_card_filename: varchar('sizes_card_filename'),
    sizes_tablet_url: varchar('sizes_tablet_url'),
    sizes_tablet_width: numeric('sizes_tablet_width', { mode: 'number' }),
    sizes_tablet_height: numeric('sizes_tablet_height', { mode: 'number' }),
    sizes_tablet_mimeType: varchar('sizes_tablet_mime_type'),
    sizes_tablet_filesize: numeric('sizes_tablet_filesize', { mode: 'number' }),
    sizes_tablet_filename: varchar('sizes_tablet_filename'),
  },
  (columns) => [
    index('media_updated_at_idx').on(columns.updatedAt),
    index('media_created_at_idx').on(columns.createdAt),
    uniqueIndex('media_filename_idx').on(columns.filename),
    index('media_sizes_thumbnail_sizes_thumbnail_filename_idx').on(
      columns.sizes_thumbnail_filename,
    ),
    index('media_sizes_card_sizes_card_filename_idx').on(columns.sizes_card_filename),
    index('media_sizes_tablet_sizes_tablet_filename_idx').on(columns.sizes_tablet_filename),
  ],
);

export const posts = pgTable(
  'posts',
  {
    id: serial('id').primaryKey(),
    date: timestamp('date', { mode: 'string', withTimezone: true, precision: 3 }),
    featuredImage: integer('featured_image_id').references(() => media.id, {
      onDelete: 'set null',
    }),
    updatedAt: timestamp('updated_at', { mode: 'string', withTimezone: true, precision: 3 })
      .defaultNow()
      .notNull(),
    createdAt: timestamp('created_at', { mode: 'string', withTimezone: true, precision: 3 })
      .defaultNow()
      .notNull(),
    _status: enum_posts_status('_status').default('draft'),
  },
  (columns) => [
    index('posts_featured_image_idx').on(columns.featuredImage),
    index('posts_updated_at_idx').on(columns.updatedAt),
    index('posts_created_at_idx').on(columns.createdAt),
    index('posts__status_idx').on(columns._status),
  ],
);

export const posts_locales = pgTable(
  'posts_locales',
  {
    title: varchar('title'),
    slug: varchar('slug'),
    excerpt: varchar('excerpt'),
    category: varchar('category'),
    content: jsonb('content'),
    id: serial('id').primaryKey(),
    _locale: enum__locales('_locale').notNull(),
    _parentID: integer('_parent_id').notNull(),
  },
  (columns) => [
    uniqueIndex('posts_locales_locale_parent_id_unique').on(columns._locale, columns._parentID),
    foreignKey({
      columns: [columns['_parentID']],
      foreignColumns: [posts.id],
      name: 'posts_locales_parent_id_fk',
    }).onDelete('cascade'),
  ],
);

export const _posts_v = pgTable(
  '_posts_v',
  {
    id: serial('id').primaryKey(),
    parent: integer('parent_id').references(() => posts.id, {
      onDelete: 'set null',
    }),
    version_date: timestamp('version_date', { mode: 'string', withTimezone: true, precision: 3 }),
    version_featuredImage: integer('version_featured_image_id').references(() => media.id, {
      onDelete: 'set null',
    }),
    version_updatedAt: timestamp('version_updated_at', {
      mode: 'string',
      withTimezone: true,
      precision: 3,
    }),
    version_createdAt: timestamp('version_created_at', {
      mode: 'string',
      withTimezone: true,
      precision: 3,
    }),
    version__status: enum__posts_v_version_status('version__status').default('draft'),
    createdAt: timestamp('created_at', { mode: 'string', withTimezone: true, precision: 3 })
      .defaultNow()
      .notNull(),
    updatedAt: timestamp('updated_at', { mode: 'string', withTimezone: true, precision: 3 })
      .defaultNow()
      .notNull(),
    snapshot: boolean('snapshot'),
    publishedLocale: enum__posts_v_published_locale('published_locale'),
    latest: boolean('latest'),
  },
  (columns) => [
    index('_posts_v_parent_idx').on(columns.parent),
    index('_posts_v_version_version_featured_image_idx').on(columns.version_featuredImage),
    index('_posts_v_version_version_updated_at_idx').on(columns.version_updatedAt),
    index('_posts_v_version_version_created_at_idx').on(columns.version_createdAt),
    index('_posts_v_version_version__status_idx').on(columns.version__status),
    index('_posts_v_created_at_idx').on(columns.createdAt),
    index('_posts_v_updated_at_idx').on(columns.updatedAt),
    index('_posts_v_snapshot_idx').on(columns.snapshot),
    index('_posts_v_published_locale_idx').on(columns.publishedLocale),
    index('_posts_v_latest_idx').on(columns.latest),
  ],
);

export const _posts_v_locales = pgTable(
  '_posts_v_locales',
  {
    version_title: varchar('version_title'),
    version_slug: varchar('version_slug'),
    version_excerpt: varchar('version_excerpt'),
    version_category: varchar('version_category'),
    version_content: jsonb('version_content'),
    id: serial('id').primaryKey(),
    _locale: enum__locales('_locale').notNull(),
    _parentID: integer('_parent_id').notNull(),
  },
  (columns) => [
    uniqueIndex('_posts_v_locales_locale_parent_id_unique').on(columns._locale, columns._parentID),
    foreignKey({
      columns: [columns['_parentID']],
      foreignColumns: [_posts_v.id],
      name: '_posts_v_locales_parent_id_fk',
    }).onDelete('cascade'),
  ],
);

export const form_submissions = pgTable(
  'form_submissions',
  {
    id: serial('id').primaryKey(),
    name: varchar('name').notNull(),
    email: varchar('email').notNull(),
    type: enum_form_submissions_type('type').notNull(),
    productName: varchar('product_name'),
    message: varchar('message').notNull(),
    updatedAt: timestamp('updated_at', { mode: 'string', withTimezone: true, precision: 3 })
      .defaultNow()
      .notNull(),
    createdAt: timestamp('created_at', { mode: 'string', withTimezone: true, precision: 3 })
      .defaultNow()
      .notNull(),
  },
  (columns) => [
    index('form_submissions_updated_at_idx').on(columns.updatedAt),
    index('form_submissions_created_at_idx').on(columns.createdAt),
  ],
);

export const products_categories = pgTable(
  'products_categories',
  {
    _order: integer('_order').notNull(),
    _parentID: integer('_parent_id').notNull(),
    id: varchar('id').primaryKey(),
    category: varchar('category'),
  },
  (columns) => [
    index('products_categories_order_idx').on(columns._order),
    index('products_categories_parent_id_idx').on(columns._parentID),
    foreignKey({
      columns: [columns['_parentID']],
      foreignColumns: [products.id],
      name: 'products_categories_parent_id_fk',
    }).onDelete('cascade'),
  ],
);

export const products = pgTable(
  'products',
  {
    id: serial('id').primaryKey(),
    sku: varchar('sku'),
    slug: varchar('slug'),
    featuredImage: integer('featured_image_id').references(() => media.id, {
      onDelete: 'set null',
    }),
    updatedAt: timestamp('updated_at', { mode: 'string', withTimezone: true, precision: 3 })
      .defaultNow()
      .notNull(),
    createdAt: timestamp('created_at', { mode: 'string', withTimezone: true, precision: 3 })
      .defaultNow()
      .notNull(),
    _status: enum_products_status('_status').default('draft'),
  },
  (columns) => [
    index('products_featured_image_idx').on(columns.featuredImage),
    index('products_updated_at_idx').on(columns.updatedAt),
    index('products_created_at_idx').on(columns.createdAt),
    index('products__status_idx').on(columns._status),
  ],
);

export const products_locales = pgTable(
  'products_locales',
  {
    title: varchar('title'),
    description: varchar('description'),
    application: jsonb('application'),
    content: jsonb('content'),
    id: serial('id').primaryKey(),
    _locale: enum__locales('_locale').notNull(),
    _parentID: integer('_parent_id').notNull(),
  },
  (columns) => [
    uniqueIndex('products_locales_locale_parent_id_unique').on(columns._locale, columns._parentID),
    foreignKey({
      columns: [columns['_parentID']],
      foreignColumns: [products.id],
      name: 'products_locales_parent_id_fk',
    }).onDelete('cascade'),
  ],
);

export const products_rels = pgTable(
  'products_rels',
  {
    id: serial('id').primaryKey(),
    order: integer('order'),
    parent: integer('parent_id').notNull(),
    path: varchar('path').notNull(),
    mediaID: integer('media_id'),
  },
  (columns) => [
    index('products_rels_order_idx').on(columns.order),
    index('products_rels_parent_idx').on(columns.parent),
    index('products_rels_path_idx').on(columns.path),
    index('products_rels_media_id_idx').on(columns.mediaID),
    foreignKey({
      columns: [columns['parent']],
      foreignColumns: [products.id],
      name: 'products_rels_parent_fk',
    }).onDelete('cascade'),
    foreignKey({
      columns: [columns['mediaID']],
      foreignColumns: [media.id],
      name: 'products_rels_media_fk',
    }).onDelete('cascade'),
  ],
);

export const _products_v_version_categories = pgTable(
  '_products_v_version_categories',
  {
    _order: integer('_order').notNull(),
    _parentID: integer('_parent_id').notNull(),
    id: serial('id').primaryKey(),
    category: varchar('category'),
    _uuid: varchar('_uuid'),
  },
  (columns) => [
    index('_products_v_version_categories_order_idx').on(columns._order),
    index('_products_v_version_categories_parent_id_idx').on(columns._parentID),
    foreignKey({
      columns: [columns['_parentID']],
      foreignColumns: [_products_v.id],
      name: '_products_v_version_categories_parent_id_fk',
    }).onDelete('cascade'),
  ],
);

export const _products_v = pgTable(
  '_products_v',
  {
    id: serial('id').primaryKey(),
    parent: integer('parent_id').references(() => products.id, {
      onDelete: 'set null',
    }),
    version_sku: varchar('version_sku'),
    version_slug: varchar('version_slug'),
    version_featuredImage: integer('version_featured_image_id').references(() => media.id, {
      onDelete: 'set null',
    }),
    version_updatedAt: timestamp('version_updated_at', {
      mode: 'string',
      withTimezone: true,
      precision: 3,
    }),
    version_createdAt: timestamp('version_created_at', {
      mode: 'string',
      withTimezone: true,
      precision: 3,
    }),
    version__status: enum__products_v_version_status('version__status').default('draft'),
    createdAt: timestamp('created_at', { mode: 'string', withTimezone: true, precision: 3 })
      .defaultNow()
      .notNull(),
    updatedAt: timestamp('updated_at', { mode: 'string', withTimezone: true, precision: 3 })
      .defaultNow()
      .notNull(),
    snapshot: boolean('snapshot'),
    publishedLocale: enum__products_v_published_locale('published_locale'),
    latest: boolean('latest'),
  },
  (columns) => [
    index('_products_v_parent_idx').on(columns.parent),
    index('_products_v_version_version_featured_image_idx').on(columns.version_featuredImage),
    index('_products_v_version_version_updated_at_idx').on(columns.version_updatedAt),
    index('_products_v_version_version_created_at_idx').on(columns.version_createdAt),
    index('_products_v_version_version__status_idx').on(columns.version__status),
    index('_products_v_created_at_idx').on(columns.createdAt),
    index('_products_v_updated_at_idx').on(columns.updatedAt),
    index('_products_v_snapshot_idx').on(columns.snapshot),
    index('_products_v_published_locale_idx').on(columns.publishedLocale),
    index('_products_v_latest_idx').on(columns.latest),
  ],
);

export const _products_v_locales = pgTable(
  '_products_v_locales',
  {
    version_title: varchar('version_title'),
    version_description: varchar('version_description'),
    version_application: jsonb('version_application'),
    version_content: jsonb('version_content'),
    id: serial('id').primaryKey(),
    _locale: enum__locales('_locale').notNull(),
    _parentID: integer('_parent_id').notNull(),
  },
  (columns) => [
    uniqueIndex('_products_v_locales_locale_parent_id_unique').on(
      columns._locale,
      columns._parentID,
    ),
    foreignKey({
      columns: [columns['_parentID']],
      foreignColumns: [_products_v.id],
      name: '_products_v_locales_parent_id_fk',
    }).onDelete('cascade'),
  ],
);

export const _products_v_rels = pgTable(
  '_products_v_rels',
  {
    id: serial('id').primaryKey(),
    order: integer('order'),
    parent: integer('parent_id').notNull(),
    path: varchar('path').notNull(),
    mediaID: integer('media_id'),
  },
  (columns) => [
    index('_products_v_rels_order_idx').on(columns.order),
    index('_products_v_rels_parent_idx').on(columns.parent),
    index('_products_v_rels_path_idx').on(columns.path),
    index('_products_v_rels_media_id_idx').on(columns.mediaID),
    foreignKey({
      columns: [columns['parent']],
      foreignColumns: [_products_v.id],
      name: '_products_v_rels_parent_fk',
    }).onDelete('cascade'),
    foreignKey({
      columns: [columns['mediaID']],
      foreignColumns: [media.id],
      name: '_products_v_rels_media_fk',
    }).onDelete('cascade'),
  ],
);

export const pages = pgTable(
  'pages',
  {
    id: serial('id').primaryKey(),
    layout: enum_pages_layout('layout').default('default'),
    featuredImage: integer('featured_image_id').references(() => media.id, {
      onDelete: 'set null',
    }),
    updatedAt: timestamp('updated_at', { mode: 'string', withTimezone: true, precision: 3 })
      .defaultNow()
      .notNull(),
    createdAt: timestamp('created_at', { mode: 'string', withTimezone: true, precision: 3 })
      .defaultNow()
      .notNull(),
    _status: enum_pages_status('_status').default('draft'),
  },
  (columns) => [
    index('pages_featured_image_idx').on(columns.featuredImage),
    index('pages_updated_at_idx').on(columns.updatedAt),
    index('pages_created_at_idx').on(columns.createdAt),
    index('pages__status_idx').on(columns._status),
  ],
);

export const pages_locales = pgTable(
  'pages_locales',
  {
    title: varchar('title'),
    slug: varchar('slug'),
    excerpt: varchar('excerpt'),
    content: jsonb('content'),
    id: serial('id').primaryKey(),
    _locale: enum__locales('_locale').notNull(),
    _parentID: integer('_parent_id').notNull(),
  },
  (columns) => [
    uniqueIndex('pages_locales_locale_parent_id_unique').on(columns._locale, columns._parentID),
    foreignKey({
      columns: [columns['_parentID']],
      foreignColumns: [pages.id],
      name: 'pages_locales_parent_id_fk',
    }).onDelete('cascade'),
  ],
);

export const _pages_v = pgTable(
  '_pages_v',
  {
    id: serial('id').primaryKey(),
    parent: integer('parent_id').references(() => pages.id, {
      onDelete: 'set null',
    }),
    version_layout: enum__pages_v_version_layout('version_layout').default('default'),
    version_featuredImage: integer('version_featured_image_id').references(() => media.id, {
      onDelete: 'set null',
    }),
    version_updatedAt: timestamp('version_updated_at', {
      mode: 'string',
      withTimezone: true,
      precision: 3,
    }),
    version_createdAt: timestamp('version_created_at', {
      mode: 'string',
      withTimezone: true,
      precision: 3,
    }),
    version__status: enum__pages_v_version_status('version__status').default('draft'),
    createdAt: timestamp('created_at', { mode: 'string', withTimezone: true, precision: 3 })
      .defaultNow()
      .notNull(),
    updatedAt: timestamp('updated_at', { mode: 'string', withTimezone: true, precision: 3 })
      .defaultNow()
      .notNull(),
    snapshot: boolean('snapshot'),
    publishedLocale: enum__pages_v_published_locale('published_locale'),
    latest: boolean('latest'),
  },
  (columns) => [
    index('_pages_v_parent_idx').on(columns.parent),
    index('_pages_v_version_version_featured_image_idx').on(columns.version_featuredImage),
    index('_pages_v_version_version_updated_at_idx').on(columns.version_updatedAt),
    index('_pages_v_version_version_created_at_idx').on(columns.version_createdAt),
    index('_pages_v_version_version__status_idx').on(columns.version__status),
    index('_pages_v_created_at_idx').on(columns.createdAt),
    index('_pages_v_updated_at_idx').on(columns.updatedAt),
    index('_pages_v_snapshot_idx').on(columns.snapshot),
    index('_pages_v_published_locale_idx').on(columns.publishedLocale),
    index('_pages_v_latest_idx').on(columns.latest),
  ],
);

export const _pages_v_locales = pgTable(
  '_pages_v_locales',
  {
    version_title: varchar('version_title'),
    version_slug: varchar('version_slug'),
    version_excerpt: varchar('version_excerpt'),
    version_content: jsonb('version_content'),
    id: serial('id').primaryKey(),
    _locale: enum__locales('_locale').notNull(),
    _parentID: integer('_parent_id').notNull(),
  },
  (columns) => [
    uniqueIndex('_pages_v_locales_locale_parent_id_unique').on(columns._locale, columns._parentID),
    foreignKey({
      columns: [columns['_parentID']],
      foreignColumns: [_pages_v.id],
      name: '_pages_v_locales_parent_id_fk',
    }).onDelete('cascade'),
  ],
);

export const payload_kv = pgTable(
  'payload_kv',
  {
    id: serial('id').primaryKey(),
    key: varchar('key').notNull(),
    data: jsonb('data').notNull(),
  },
  (columns) => [uniqueIndex('payload_kv_key_idx').on(columns.key)],
);

export const payload_locked_documents = pgTable(
  'payload_locked_documents',
  {
    id: serial('id').primaryKey(),
    globalSlug: varchar('global_slug'),
    updatedAt: timestamp('updated_at', { mode: 'string', withTimezone: true, precision: 3 })
      .defaultNow()
      .notNull(),
    createdAt: timestamp('created_at', { mode: 'string', withTimezone: true, precision: 3 })
      .defaultNow()
      .notNull(),
  },
  (columns) => [
    index('payload_locked_documents_global_slug_idx').on(columns.globalSlug),
    index('payload_locked_documents_updated_at_idx').on(columns.updatedAt),
    index('payload_locked_documents_created_at_idx').on(columns.createdAt),
  ],
);

export const payload_locked_documents_rels = pgTable(
  'payload_locked_documents_rels',
  {
    id: serial('id').primaryKey(),
    order: integer('order'),
    parent: integer('parent_id').notNull(),
    path: varchar('path').notNull(),
    usersID: integer('users_id'),
    mediaID: integer('media_id'),
    postsID: integer('posts_id'),
    'form-submissionsID': integer('form_submissions_id'),
    productsID: integer('products_id'),
    pagesID: integer('pages_id'),
  },
  (columns) => [
    index('payload_locked_documents_rels_order_idx').on(columns.order),
    index('payload_locked_documents_rels_parent_idx').on(columns.parent),
    index('payload_locked_documents_rels_path_idx').on(columns.path),
    index('payload_locked_documents_rels_users_id_idx').on(columns.usersID),
    index('payload_locked_documents_rels_media_id_idx').on(columns.mediaID),
    index('payload_locked_documents_rels_posts_id_idx').on(columns.postsID),
    index('payload_locked_documents_rels_form_submissions_id_idx').on(
      columns['form-submissionsID'],
    ),
    index('payload_locked_documents_rels_products_id_idx').on(columns.productsID),
    index('payload_locked_documents_rels_pages_id_idx').on(columns.pagesID),
    foreignKey({
      columns: [columns['parent']],
      foreignColumns: [payload_locked_documents.id],
      name: 'payload_locked_documents_rels_parent_fk',
    }).onDelete('cascade'),
    foreignKey({
      columns: [columns['usersID']],
      foreignColumns: [users.id],
      name: 'payload_locked_documents_rels_users_fk',
    }).onDelete('cascade'),
    foreignKey({
      columns: [columns['mediaID']],
      foreignColumns: [media.id],
      name: 'payload_locked_documents_rels_media_fk',
    }).onDelete('cascade'),
    foreignKey({
      columns: [columns['postsID']],
      foreignColumns: [posts.id],
      name: 'payload_locked_documents_rels_posts_fk',
    }).onDelete('cascade'),
    foreignKey({
      columns: [columns['form-submissionsID']],
      foreignColumns: [form_submissions.id],
      name: 'payload_locked_documents_rels_form_submissions_fk',
    }).onDelete('cascade'),
    foreignKey({
      columns: [columns['productsID']],
      foreignColumns: [products.id],
      name: 'payload_locked_documents_rels_products_fk',
    }).onDelete('cascade'),
    foreignKey({
      columns: [columns['pagesID']],
      foreignColumns: [pages.id],
      name: 'payload_locked_documents_rels_pages_fk',
    }).onDelete('cascade'),
  ],
);

export const payload_preferences = pgTable(
  'payload_preferences',
  {
    id: serial('id').primaryKey(),
    key: varchar('key'),
    value: jsonb('value'),
    updatedAt: timestamp('updated_at', { mode: 'string', withTimezone: true, precision: 3 })
      .defaultNow()
      .notNull(),
    createdAt: timestamp('created_at', { mode: 'string', withTimezone: true, precision: 3 })
      .defaultNow()
      .notNull(),
  },
  (columns) => [
    index('payload_preferences_key_idx').on(columns.key),
    index('payload_preferences_updated_at_idx').on(columns.updatedAt),
    index('payload_preferences_created_at_idx').on(columns.createdAt),
  ],
);

export const payload_preferences_rels = pgTable(
  'payload_preferences_rels',
  {
    id: serial('id').primaryKey(),
    order: integer('order'),
    parent: integer('parent_id').notNull(),
    path: varchar('path').notNull(),
    usersID: integer('users_id'),
  },
  (columns) => [
    index('payload_preferences_rels_order_idx').on(columns.order),
    index('payload_preferences_rels_parent_idx').on(columns.parent),
    index('payload_preferences_rels_path_idx').on(columns.path),
    index('payload_preferences_rels_users_id_idx').on(columns.usersID),
    foreignKey({
      columns: [columns['parent']],
      foreignColumns: [payload_preferences.id],
      name: 'payload_preferences_rels_parent_fk',
    }).onDelete('cascade'),
    foreignKey({
      columns: [columns['usersID']],
      foreignColumns: [users.id],
      name: 'payload_preferences_rels_users_fk',
    }).onDelete('cascade'),
  ],
);

export const payload_migrations = pgTable(
  'payload_migrations',
  {
    id: serial('id').primaryKey(),
    name: varchar('name'),
    batch: numeric('batch', { mode: 'number' }),
    updatedAt: timestamp('updated_at', { mode: 'string', withTimezone: true, precision: 3 })
      .defaultNow()
      .notNull(),
    createdAt: timestamp('created_at', { mode: 'string', withTimezone: true, precision: 3 })
      .defaultNow()
      .notNull(),
  },
  (columns) => [
    index('payload_migrations_updated_at_idx').on(columns.updatedAt),
    index('payload_migrations_created_at_idx').on(columns.createdAt),
  ],
);

export const relations_users_sessions = relations(users_sessions, ({ one }) => ({
  _parentID: one(users, {
    fields: [users_sessions._parentID],
    references: [users.id],
    relationName: 'sessions',
  }),
}));
export const relations_users = relations(users, ({ many }) => ({
  sessions: many(users_sessions, {
    relationName: 'sessions',
  }),
}));
export const relations_media = relations(media, () => ({}));
export const relations_posts_locales = relations(posts_locales, ({ one }) => ({
  _parentID: one(posts, {
    fields: [posts_locales._parentID],
    references: [posts.id],
    relationName: '_locales',
  }),
}));
export const relations_posts = relations(posts, ({ one, many }) => ({
  featuredImage: one(media, {
    fields: [posts.featuredImage],
    references: [media.id],
    relationName: 'featuredImage',
  }),
  _locales: many(posts_locales, {
    relationName: '_locales',
  }),
}));
export const relations__posts_v_locales = relations(_posts_v_locales, ({ one }) => ({
  _parentID: one(_posts_v, {
    fields: [_posts_v_locales._parentID],
    references: [_posts_v.id],
    relationName: '_locales',
  }),
}));
export const relations__posts_v = relations(_posts_v, ({ one, many }) => ({
  parent: one(posts, {
    fields: [_posts_v.parent],
    references: [posts.id],
    relationName: 'parent',
  }),
  version_featuredImage: one(media, {
    fields: [_posts_v.version_featuredImage],
    references: [media.id],
    relationName: 'version_featuredImage',
  }),
  _locales: many(_posts_v_locales, {
    relationName: '_locales',
  }),
}));
export const relations_form_submissions = relations(form_submissions, () => ({}));
export const relations_products_categories = relations(products_categories, ({ one }) => ({
  _parentID: one(products, {
    fields: [products_categories._parentID],
    references: [products.id],
    relationName: 'categories',
  }),
}));
export const relations_products_locales = relations(products_locales, ({ one }) => ({
  _parentID: one(products, {
    fields: [products_locales._parentID],
    references: [products.id],
    relationName: '_locales',
  }),
}));
export const relations_products_rels = relations(products_rels, ({ one }) => ({
  parent: one(products, {
    fields: [products_rels.parent],
    references: [products.id],
    relationName: '_rels',
  }),
  mediaID: one(media, {
    fields: [products_rels.mediaID],
    references: [media.id],
    relationName: 'media',
  }),
}));
export const relations_products = relations(products, ({ one, many }) => ({
  categories: many(products_categories, {
    relationName: 'categories',
  }),
  featuredImage: one(media, {
    fields: [products.featuredImage],
    references: [media.id],
    relationName: 'featuredImage',
  }),
  _locales: many(products_locales, {
    relationName: '_locales',
  }),
  _rels: many(products_rels, {
    relationName: '_rels',
  }),
}));
export const relations__products_v_version_categories = relations(
  _products_v_version_categories,
  ({ one }) => ({
    _parentID: one(_products_v, {
      fields: [_products_v_version_categories._parentID],
      references: [_products_v.id],
      relationName: 'version_categories',
    }),
  }),
);
export const relations__products_v_locales = relations(_products_v_locales, ({ one }) => ({
  _parentID: one(_products_v, {
    fields: [_products_v_locales._parentID],
    references: [_products_v.id],
    relationName: '_locales',
  }),
}));
export const relations__products_v_rels = relations(_products_v_rels, ({ one }) => ({
  parent: one(_products_v, {
    fields: [_products_v_rels.parent],
    references: [_products_v.id],
    relationName: '_rels',
  }),
  mediaID: one(media, {
    fields: [_products_v_rels.mediaID],
    references: [media.id],
    relationName: 'media',
  }),
}));
export const relations__products_v = relations(_products_v, ({ one, many }) => ({
  parent: one(products, {
    fields: [_products_v.parent],
    references: [products.id],
    relationName: 'parent',
  }),
  version_categories: many(_products_v_version_categories, {
    relationName: 'version_categories',
  }),
  version_featuredImage: one(media, {
    fields: [_products_v.version_featuredImage],
    references: [media.id],
    relationName: 'version_featuredImage',
  }),
  _locales: many(_products_v_locales, {
    relationName: '_locales',
  }),
  _rels: many(_products_v_rels, {
    relationName: '_rels',
  }),
}));
export const relations_pages_locales = relations(pages_locales, ({ one }) => ({
  _parentID: one(pages, {
    fields: [pages_locales._parentID],
    references: [pages.id],
    relationName: '_locales',
  }),
}));
export const relations_pages = relations(pages, ({ one, many }) => ({
  featuredImage: one(media, {
    fields: [pages.featuredImage],
    references: [media.id],
    relationName: 'featuredImage',
  }),
  _locales: many(pages_locales, {
    relationName: '_locales',
  }),
}));
export const relations__pages_v_locales = relations(_pages_v_locales, ({ one }) => ({
  _parentID: one(_pages_v, {
    fields: [_pages_v_locales._parentID],
    references: [_pages_v.id],
    relationName: '_locales',
  }),
}));
export const relations__pages_v = relations(_pages_v, ({ one, many }) => ({
  parent: one(pages, {
    fields: [_pages_v.parent],
    references: [pages.id],
    relationName: 'parent',
  }),
  version_featuredImage: one(media, {
    fields: [_pages_v.version_featuredImage],
    references: [media.id],
    relationName: 'version_featuredImage',
  }),
  _locales: many(_pages_v_locales, {
    relationName: '_locales',
  }),
}));
export const relations_payload_kv = relations(payload_kv, () => ({}));
export const relations_payload_locked_documents_rels = relations(
  payload_locked_documents_rels,
  ({ one }) => ({
    parent: one(payload_locked_documents, {
      fields: [payload_locked_documents_rels.parent],
      references: [payload_locked_documents.id],
      relationName: '_rels',
    }),
    usersID: one(users, {
      fields: [payload_locked_documents_rels.usersID],
      references: [users.id],
      relationName: 'users',
    }),
    mediaID: one(media, {
      fields: [payload_locked_documents_rels.mediaID],
      references: [media.id],
      relationName: 'media',
    }),
    postsID: one(posts, {
      fields: [payload_locked_documents_rels.postsID],
      references: [posts.id],
      relationName: 'posts',
    }),
    'form-submissionsID': one(form_submissions, {
      fields: [payload_locked_documents_rels['form-submissionsID']],
      references: [form_submissions.id],
      relationName: 'form-submissions',
    }),
    productsID: one(products, {
      fields: [payload_locked_documents_rels.productsID],
      references: [products.id],
      relationName: 'products',
    }),
    pagesID: one(pages, {
      fields: [payload_locked_documents_rels.pagesID],
      references: [pages.id],
      relationName: 'pages',
    }),
  }),
);
export const relations_payload_locked_documents = relations(
  payload_locked_documents,
  ({ many }) => ({
    _rels: many(payload_locked_documents_rels, {
      relationName: '_rels',
    }),
  }),
);
export const relations_payload_preferences_rels = relations(
  payload_preferences_rels,
  ({ one }) => ({
    parent: one(payload_preferences, {
      fields: [payload_preferences_rels.parent],
      references: [payload_preferences.id],
      relationName: '_rels',
    }),
    usersID: one(users, {
      fields: [payload_preferences_rels.usersID],
      references: [users.id],
      relationName: 'users',
    }),
  }),
);
export const relations_payload_preferences = relations(payload_preferences, ({ many }) => ({
  _rels: many(payload_preferences_rels, {
    relationName: '_rels',
  }),
}));
export const relations_payload_migrations = relations(payload_migrations, () => ({}));

type DatabaseSchema = {
  enum__locales: typeof enum__locales;
  enum_posts_status: typeof enum_posts_status;
  enum__posts_v_version_status: typeof enum__posts_v_version_status;
  enum__posts_v_published_locale: typeof enum__posts_v_published_locale;
  enum_form_submissions_type: typeof enum_form_submissions_type;
  enum_products_status: typeof enum_products_status;
  enum__products_v_version_status: typeof enum__products_v_version_status;
  enum__products_v_published_locale: typeof enum__products_v_published_locale;
  enum_pages_layout: typeof enum_pages_layout;
  enum_pages_status: typeof enum_pages_status;
  enum__pages_v_version_layout: typeof enum__pages_v_version_layout;
  enum__pages_v_version_status: typeof enum__pages_v_version_status;
  enum__pages_v_published_locale: typeof enum__pages_v_published_locale;
  users_sessions: typeof users_sessions;
  users: typeof users;
  media: typeof media;
  posts: typeof posts;
  posts_locales: typeof posts_locales;
  _posts_v: typeof _posts_v;
  _posts_v_locales: typeof _posts_v_locales;
  form_submissions: typeof form_submissions;
  products_categories: typeof products_categories;
  products: typeof products;
  products_locales: typeof products_locales;
  products_rels: typeof products_rels;
  _products_v_version_categories: typeof _products_v_version_categories;
  _products_v: typeof _products_v;
  _products_v_locales: typeof _products_v_locales;
  _products_v_rels: typeof _products_v_rels;
  pages: typeof pages;
  pages_locales: typeof pages_locales;
  _pages_v: typeof _pages_v;
  _pages_v_locales: typeof _pages_v_locales;
  payload_kv: typeof payload_kv;
  payload_locked_documents: typeof payload_locked_documents;
  payload_locked_documents_rels: typeof payload_locked_documents_rels;
  payload_preferences: typeof payload_preferences;
  payload_preferences_rels: typeof payload_preferences_rels;
  payload_migrations: typeof payload_migrations;
  relations_users_sessions: typeof relations_users_sessions;
  relations_users: typeof relations_users;
  relations_media: typeof relations_media;
  relations_posts_locales: typeof relations_posts_locales;
  relations_posts: typeof relations_posts;
  relations__posts_v_locales: typeof relations__posts_v_locales;
  relations__posts_v: typeof relations__posts_v;
  relations_form_submissions: typeof relations_form_submissions;
  relations_products_categories: typeof relations_products_categories;
  relations_products_locales: typeof relations_products_locales;
  relations_products_rels: typeof relations_products_rels;
  relations_products: typeof relations_products;
  relations__products_v_version_categories: typeof relations__products_v_version_categories;
  relations__products_v_locales: typeof relations__products_v_locales;
  relations__products_v_rels: typeof relations__products_v_rels;
  relations__products_v: typeof relations__products_v;
  relations_pages_locales: typeof relations_pages_locales;
  relations_pages: typeof relations_pages;
  relations__pages_v_locales: typeof relations__pages_v_locales;
  relations__pages_v: typeof relations__pages_v;
  relations_payload_kv: typeof relations_payload_kv;
  relations_payload_locked_documents_rels: typeof relations_payload_locked_documents_rels;
  relations_payload_locked_documents: typeof relations_payload_locked_documents;
  relations_payload_preferences_rels: typeof relations_payload_preferences_rels;
  relations_payload_preferences: typeof relations_payload_preferences;
  relations_payload_migrations: typeof relations_payload_migrations;
};

declare module '@payloadcms/db-postgres' {
  export interface GeneratedDatabaseSchema {
    schema: DatabaseSchema;
  }
}
