From 7cf47d446175b3a6013f178bfd090a03dd478999 Mon Sep 17 00:00:00 2001 From: Mehmet Date: Fri, 20 Dec 2024 23:11:17 +0100 Subject: [PATCH 1/7] fix: added missing seo for termen pages --- .changeset/cyan-moose-rescue.md | 5 + .../app/termen/[...slug]/get-parsed-term.ts | 81 ++++++++++++++++ apps/web/src/app/termen/[...slug]/page.tsx | 97 ++++--------------- 3 files changed, 106 insertions(+), 77 deletions(-) create mode 100644 .changeset/cyan-moose-rescue.md create mode 100644 apps/web/src/app/termen/[...slug]/get-parsed-term.ts diff --git a/.changeset/cyan-moose-rescue.md b/.changeset/cyan-moose-rescue.md new file mode 100644 index 00000000..fd2f9190 --- /dev/null +++ b/.changeset/cyan-moose-rescue.md @@ -0,0 +1,5 @@ +--- +"web": patch +--- + +Added SEO tags for `/termen/*` pages diff --git a/apps/web/src/app/termen/[...slug]/get-parsed-term.ts b/apps/web/src/app/termen/[...slug]/get-parsed-term.ts new file mode 100644 index 00000000..27226164 --- /dev/null +++ b/apps/web/src/app/termen/[...slug]/get-parsed-term.ts @@ -0,0 +1,81 @@ +import { resolveCmsImage } from '@/common/resolve-cms-image'; +import { findTermInFormat } from '../find-term-in-format'; + +type Args = { + slug: string; +}; + +interface FindFieldArgs { + input: Record; + key: string; + value: string; +} + +function findNodeWithField({ input, key, value }: FindFieldArgs): Record | null { + let result: Record | null = null; + + function search(obj: Record) { + if (typeof obj !== 'object' || obj === null) return; + + for (const inputKey in obj) { + if (inputKey === key && obj[inputKey] === value) { + result = obj; + return; + } + + if (typeof obj[inputKey] === 'object') { + search(obj[inputKey]); + if (result) return; + } + } + } + + search(input); + + return result; +} + +export async function getParsedTerm({ slug }: Args) { + const term = await findTermInFormat({ slug, extension: '.json' }); + + const json = await await fetch(resolveCmsImage(term.files as any), { + method: 'GET', + }).then((res) => res.json() as Record); + + const rootNode = findNodeWithField({ + input: json, + key: '@id', + value: `https://regels.overheid.nl/termen${slug}`, + }); + + const nlPrefLabelNode = findNodeWithField({ + input: rootNode?.['http://www.w3.org/2004/02/skos/core#prefLabel'] || {}, + key: '@language', + value: 'nl', + }); + + const nlDefinitionNode = findNodeWithField({ + input: rootNode?.['http://www.w3.org/2004/02/skos/core#definition'] || {}, + key: '@language', + value: 'nl', + }); + + const nlScopeNoteNode = findNodeWithField({ + input: rootNode?.['http://www.w3.org/2004/02/skos/core#scopeNote'] || {}, + key: '@language', + value: 'nl', + }); + + const nlLabelNode = findNodeWithField({ + input: rootNode?.['http://www.w3.org/2000/01/rdf-schema#label'] || {}, + key: '@language', + value: 'nl', + }); + + return { + nlLabel: nlLabelNode?.['@value'], + nlScopeNote: nlScopeNoteNode?.['@value'], + nlPrefLabel: nlPrefLabelNode?.['@value'], + nlDefinition: nlDefinitionNode?.['@value'], + }; +} diff --git a/apps/web/src/app/termen/[...slug]/page.tsx b/apps/web/src/app/termen/[...slug]/page.tsx index f23572ca..ad4ca477 100644 --- a/apps/web/src/app/termen/[...slug]/page.tsx +++ b/apps/web/src/app/termen/[...slug]/page.tsx @@ -1,86 +1,18 @@ -import { resolveCmsImage } from '@/common/resolve-cms-image'; import { Button } from '@/components/button'; -import { Chip } from '@/components/chip'; import { Container } from '@/components/container'; import { Pill } from '@/components/pill'; import { Typography } from '@/components/typography'; -import { db } from '@/drizzle/db'; -import { files, filesRelatedMorphs, terms } from '@/drizzle/schema'; -import { and, eq } from 'drizzle-orm'; import { notFound } from 'next/navigation'; -import path from 'path'; -import { findTermInFormat } from '../find-term-in-format'; import { getSlugFromParams } from '../get-slug-from-params'; +import { getParsedTerm } from './get-parsed-term'; -interface FindFieldArgs { - input: Record; - key: string; - value: string; -} - -function findNodeWithField({ input, key, value }: FindFieldArgs): Record | null { - let result: Record | null = null; - - function search(obj: Record) { - if (typeof obj !== 'object' || obj === null) return; - - for (const inputKey in obj) { - if (inputKey === key && obj[inputKey] === value) { - result = obj; - return; - } - - if (typeof obj[inputKey] === 'object') { - search(obj[inputKey]); - if (result) return; - } - } - } +type Args = { + params: { slug: string[] }; +}; - search(input); - - return result; -} - -export default async function TermenPage({ params }: { params: { slug: string[] } }) { +export default async function TermenPage({ params }: Args) { const slug = getSlugFromParams(params.slug); - const term = await findTermInFormat({ slug, extension: '.json' }); - - const json = await await fetch(resolveCmsImage(term.files as any), { - method: 'GET', - }).then((res) => res.json() as Record); - - const rootNode = findNodeWithField({ - input: json, - key: '@id', - value: `https://regels.overheid.nl/termen${slug}`, - }); - - const nlPrefLabelNode = findNodeWithField({ - input: rootNode?.['http://www.w3.org/2004/02/skos/core#prefLabel'] || {}, - key: '@language', - value: 'nl', - }); - - const nlLabelNode = findNodeWithField({ - input: rootNode?.['http://www.w3.org/2000/01/rdf-schema#label'] || {}, - key: '@language', - value: 'nl', - }); - - const nlScopeNoteNode = findNodeWithField({ - input: rootNode?.['http://www.w3.org/2004/02/skos/core#scopeNote'] || {}, - key: '@language', - value: 'nl', - }); - - const nlDefinitionNode = findNodeWithField({ - input: rootNode?.['http://www.w3.org/2004/02/skos/core#definition'] || {}, - key: '@language', - value: 'nl', - }); - - const nlPrefLabel = nlPrefLabelNode?.['@value']; + const { nlDefinition, nlPrefLabel, nlScopeNote, nlLabel } = await getParsedTerm({ slug }); if (!nlPrefLabel) return notFound(); @@ -91,11 +23,12 @@ export default async function TermenPage({ params }: { params: { slug: string[] Label - {nlLabelNode?.['@value']} + {nlLabel} Definitie - {nlDefinitionNode?.['@value']} + {nlDefinition} Scope notitie - {nlScopeNoteNode?.['@value']} + {nlScopeNote} + {nlDefinition} Download
+ +); diff --git a/apps/web/src/app/publicaties/[slug]/download/get-publication-file-by-slug.ts b/apps/web/src/app/publicaties/[slug]/download/get-publication-file-by-slug.ts new file mode 100644 index 00000000..f5e63dbb --- /dev/null +++ b/apps/web/src/app/publicaties/[slug]/download/get-publication-file-by-slug.ts @@ -0,0 +1,19 @@ +import { db } from '@/drizzle/db'; +import { files, filesRelatedMorphs, publications } from '@/drizzle/schema'; +import { and, eq } from 'drizzle-orm'; + +interface Args { + slug: string; +} + +export async function getPublicationFileBySlug({ slug }: Args) { + const [result] = await db + .select({ file: files }) + .from(publications) + .leftJoin(filesRelatedMorphs, eq(publications.id, filesRelatedMorphs.relatedId)) + .leftJoin(files, eq(files.id, filesRelatedMorphs.fileId)) + .where(and(eq(publications.slug, slug), eq(filesRelatedMorphs.relatedType, 'api::publication.publication'))) + .limit(1); + + return result.file; +} diff --git a/apps/web/src/app/publicaties/[slug]/download/route.ts b/apps/web/src/app/publicaties/[slug]/download/route.ts new file mode 100644 index 00000000..0b2c072f --- /dev/null +++ b/apps/web/src/app/publicaties/[slug]/download/route.ts @@ -0,0 +1,22 @@ +import { resolveCmsImage } from '@/common/resolve-cms-image'; +import slugify from '@sindresorhus/slugify'; +import { NextRequest } from 'next/server'; +import { getPublicationFileBySlug } from './get-publication-file-by-slug'; + +export async function GET(req: NextRequest, { params }: { params: { slug: string } }) { + const file = await getPublicationFileBySlug({ slug: params.slug }); + + const fetchResponse = await fetch(resolveCmsImage(file as any), { + method: 'GET', + }); + + const headers = new Headers(); + + headers.set('Content-Disposition', `attachment; filename="${slugify(params.slug)}${file?.ext}"`); + headers.set('Content-Type', file?.mime || ''); + + return new Response(fetchResponse.body, { + headers, + status: fetchResponse.status, + }); +} diff --git a/apps/web/src/app/publicaties/[slug]/get-publication-by-slug.ts b/apps/web/src/app/publicaties/[slug]/get-publication-by-slug.ts new file mode 100644 index 00000000..64f5dd7b --- /dev/null +++ b/apps/web/src/app/publicaties/[slug]/get-publication-by-slug.ts @@ -0,0 +1,13 @@ +import { db } from '@/drizzle/db'; +import { publications } from '@/drizzle/schema'; +import { eq } from 'drizzle-orm'; + +interface Args { + slug: string; +} + +export async function getPublicationBySlug({ slug }: Args) { + const [publication] = await db.select().from(publications).where(eq(publications.slug, slug)).limit(1); + + return publication; +} diff --git a/apps/web/src/app/publicaties/[slug]/page.tsx b/apps/web/src/app/publicaties/[slug]/page.tsx new file mode 100644 index 00000000..cfa21e5b --- /dev/null +++ b/apps/web/src/app/publicaties/[slug]/page.tsx @@ -0,0 +1,120 @@ +import { EnhanceMenuBreadcrumbs } from '@/app/menu-breadcrumbs'; +import { Button } from '@/components/button'; +import { Container } from '@/components/container'; +import * as Dialog from '@/components/dialog'; +import { Pill } from '@/components/pill'; +import { RemoteMdx } from '@/components/remote-mdx'; +import { Typography } from '@/components/typography'; +import { IconArrowLeft, IconBlockquote, IconDownload, IconExternalLink, IconFileTypePdf } from '@tabler/icons-react'; +import { format } from 'date-fns'; +import Link from 'next/link'; +import { CopyCiteToClipboard } from './copy-cite-to-clipboard'; +import { getPublicationBySlug } from './get-publication-by-slug'; + +type Args = { params: { slug: string } }; + +export default async function PublicatiesSlugPage({ params }: Args) { + const publication = await getPublicationBySlug({ slug: params.slug }); + + return ( + <> + + + {publication.title} +
+ + Gepubliceerd op: {format(publication.updatedAt!, 'dd MMMM yyyy')} + + Auteurs: {publication.authors} + Locatie: {publication.location} +
+
+
    +
  • + + + + + + + Citeer deze publicatie + + {publication.cite} +
    + +
    +
    +
    +
    +
    +
  • +
  • + +
  • +
  • + +
  • +
+
+
+ +
+ Samenvatting + +
+
+ Trefwoorden +
    + {publication.tags?.split(',').map((tag) => ( + + ))} +
+
+
+ +
+ + +
+
+ + ); +} + +export async function generateMetadata({ params }: Args) { + const publication = await getPublicationBySlug({ slug: params.slug }); + + return { + title: publication.title + ' - Regelregister van de Nederlandse Overheid', + keywords: publication.tags, + authors: publication.authors?.split(',').map((author) => ({ name: author.trim() })), + description: publication.summary, + }; +} diff --git a/apps/web/src/app/publicaties/card-publication.tsx b/apps/web/src/app/publicaties/card-publication.tsx new file mode 100644 index 00000000..c1c95cd4 --- /dev/null +++ b/apps/web/src/app/publicaties/card-publication.tsx @@ -0,0 +1,26 @@ +import { Pill } from '@/components/pill'; +import { Typography } from '@/components/typography'; +import { getPublications } from './get-publications'; +import Link from 'next/link'; + +interface Props { + publication: Awaited>[number]; +} + +export const CardPublication: React.FC = ({ publication }) => { + if (!publication.slug || !publication.title || !publication.summary) return null; + + return ( + + + {publication.title} + + {publication.summary} +
+ {publication.tags?.split(',').map((tag) => ( + + ))} +
+ + ); +}; diff --git a/apps/web/src/app/publicaties/get-publications.ts b/apps/web/src/app/publicaties/get-publications.ts new file mode 100644 index 00000000..c9a71f63 --- /dev/null +++ b/apps/web/src/app/publicaties/get-publications.ts @@ -0,0 +1,11 @@ +import { db } from '@/drizzle/db'; +import { publications } from '@/drizzle/schema'; +import { and, desc, lte } from 'drizzle-orm'; + +export function getPublications() { + return db + .select() + .from(publications) + .orderBy(desc(publications.publicationDate)) + .where(and(lte(publications.publishedAt, new Date().toISOString()))); +} diff --git a/apps/web/src/app/publicaties/page.tsx b/apps/web/src/app/publicaties/page.tsx new file mode 100644 index 00000000..d6e5e056 --- /dev/null +++ b/apps/web/src/app/publicaties/page.tsx @@ -0,0 +1,28 @@ +import { Container } from '@/components/container'; +import { RemotePage } from '@/components/remote-page'; +import { Typography } from '@/components/typography'; +import { Metadata } from 'next'; +import { CardPublication } from './card-publication'; +import { getPublications } from './get-publications'; + +export default async function PublicatiesPage() { + const publications = await getPublications(); + + return ( + <> + + Publicaties + +
+ {publications.map((publication) => ( + + ))} +
+
+ + ); +} + +export const metadata: Metadata = { + title: 'Regelregister van de Nederlandse Overheid - Publicaties', +}; From 80f86fa446820b5838fd03b21a509d20235b66c8 Mon Sep 17 00:00:00 2001 From: Steven Gort Date: Mon, 6 Jan 2025 10:22:49 +0100 Subject: [PATCH 6/7] changed publication date reference --- apps/web/src/app/publicaties/[slug]/page.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/web/src/app/publicaties/[slug]/page.tsx b/apps/web/src/app/publicaties/[slug]/page.tsx index cfa21e5b..854a4ac6 100644 --- a/apps/web/src/app/publicaties/[slug]/page.tsx +++ b/apps/web/src/app/publicaties/[slug]/page.tsx @@ -23,7 +23,7 @@ export default async function PublicatiesSlugPage({ params }: Args) { {publication.title}
- Gepubliceerd op: {format(publication.updatedAt!, 'dd MMMM yyyy')} + Gepubliceerd op: {format(publication.publicationDate!, 'dd MMMM yyyy')} Auteurs: {publication.authors} Locatie: {publication.location} From 4b958cfad9b9291770beff3224f39f148da198e5 Mon Sep 17 00:00:00 2001 From: Steven Gort Date: Mon, 6 Jan 2025 10:26:02 +0100 Subject: [PATCH 7/7] ran prettier --- apps/web/src/drizzle/schema.ts | 1498 +++++++++++++++++--------------- 1 file changed, 820 insertions(+), 678 deletions(-) diff --git a/apps/web/src/drizzle/schema.ts b/apps/web/src/drizzle/schema.ts index 6532656a..d5998ad6 100644 --- a/apps/web/src/drizzle/schema.ts +++ b/apps/web/src/drizzle/schema.ts @@ -1,678 +1,820 @@ -import { pgTable, serial, varchar, timestamp, json, text, jsonb, boolean, index, foreignKey, integer, bigint, numeric, unique, date, doublePrecision } from "drizzle-orm/pg-core" - import { sql } from "drizzle-orm" - - - -export const strapiMigrations = pgTable("strapi_migrations", { - id: serial("id").primaryKey().notNull(), - name: varchar("name", { length: 255 }), - time: timestamp("time", { mode: 'string' }), -}); - -export const strapiDatabaseSchema = pgTable("strapi_database_schema", { - id: serial("id").primaryKey().notNull(), - schema: json("schema"), - time: timestamp("time", { mode: 'string' }), - hash: varchar("hash", { length: 255 }), -}); - -export const strapiCoreStoreSettings = pgTable("strapi_core_store_settings", { - id: serial("id").primaryKey().notNull(), - key: varchar("key", { length: 255 }), - value: text("value"), - type: varchar("type", { length: 255 }), - environment: varchar("environment", { length: 255 }), - tag: varchar("tag", { length: 255 }), -}); - -export const strapiWebhooks = pgTable("strapi_webhooks", { - id: serial("id").primaryKey().notNull(), - name: varchar("name", { length: 255 }), - url: text("url"), - headers: jsonb("headers"), - events: jsonb("events"), - enabled: boolean("enabled"), -}); - -export const adminUsers = pgTable("admin_users", { - id: serial("id").primaryKey().notNull(), - firstname: varchar("firstname", { length: 255 }), - lastname: varchar("lastname", { length: 255 }), - username: varchar("username", { length: 255 }), - email: varchar("email", { length: 255 }), - password: varchar("password", { length: 255 }), - resetPasswordToken: varchar("reset_password_token", { length: 255 }), - registrationToken: varchar("registration_token", { length: 255 }), - isActive: boolean("is_active"), - blocked: boolean("blocked"), - preferedLanguage: varchar("prefered_language", { length: 255 }), - createdAt: timestamp("created_at", { precision: 6, mode: 'string' }), - updatedAt: timestamp("updated_at", { precision: 6, mode: 'string' }), - createdById: integer("created_by_id"), - updatedById: integer("updated_by_id"), -}, -(table) => { - return { - createdByIdFk: index("admin_users_created_by_id_fk").on(table.createdById), - updatedByIdFk: index("admin_users_updated_by_id_fk").on(table.updatedById), - adminUsersCreatedByIdFk: foreignKey({ - columns: [table.createdById], - foreignColumns: [table.id], - name: "admin_users_created_by_id_fk" - }).onDelete("set null"), - adminUsersUpdatedByIdFk: foreignKey({ - columns: [table.updatedById], - foreignColumns: [table.id], - name: "admin_users_updated_by_id_fk" - }).onDelete("set null"), - } -}); - -export const adminPermissions = pgTable("admin_permissions", { - id: serial("id").primaryKey().notNull(), - action: varchar("action", { length: 255 }), - actionParameters: jsonb("action_parameters"), - subject: varchar("subject", { length: 255 }), - properties: jsonb("properties"), - conditions: jsonb("conditions"), - createdAt: timestamp("created_at", { precision: 6, mode: 'string' }), - updatedAt: timestamp("updated_at", { precision: 6, mode: 'string' }), - createdById: integer("created_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), - updatedById: integer("updated_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), -}, -(table) => { - return { - createdByIdFk: index("admin_permissions_created_by_id_fk").on(table.createdById), - updatedByIdFk: index("admin_permissions_updated_by_id_fk").on(table.updatedById), - } -}); - -export const adminRoles = pgTable("admin_roles", { - id: serial("id").primaryKey().notNull(), - name: varchar("name", { length: 255 }), - code: varchar("code", { length: 255 }), - description: varchar("description", { length: 255 }), - createdAt: timestamp("created_at", { precision: 6, mode: 'string' }), - updatedAt: timestamp("updated_at", { precision: 6, mode: 'string' }), - createdById: integer("created_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), - updatedById: integer("updated_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), -}, -(table) => { - return { - createdByIdFk: index("admin_roles_created_by_id_fk").on(table.createdById), - updatedByIdFk: index("admin_roles_updated_by_id_fk").on(table.updatedById), - } -}); - -export const strapiApiTokens = pgTable("strapi_api_tokens", { - id: serial("id").primaryKey().notNull(), - name: varchar("name", { length: 255 }), - description: varchar("description", { length: 255 }), - type: varchar("type", { length: 255 }), - accessKey: varchar("access_key", { length: 255 }), - lastUsedAt: timestamp("last_used_at", { precision: 6, mode: 'string' }), - expiresAt: timestamp("expires_at", { precision: 6, mode: 'string' }), - // You can use { mode: "bigint" } if numbers are exceeding js number limitations - lifespan: bigint("lifespan", { mode: "number" }), - createdAt: timestamp("created_at", { precision: 6, mode: 'string' }), - updatedAt: timestamp("updated_at", { precision: 6, mode: 'string' }), - createdById: integer("created_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), - updatedById: integer("updated_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), -}, -(table) => { - return { - createdByIdFk: index("strapi_api_tokens_created_by_id_fk").on(table.createdById), - updatedByIdFk: index("strapi_api_tokens_updated_by_id_fk").on(table.updatedById), - } -}); - -export const strapiApiTokenPermissions = pgTable("strapi_api_token_permissions", { - id: serial("id").primaryKey().notNull(), - action: varchar("action", { length: 255 }), - createdAt: timestamp("created_at", { precision: 6, mode: 'string' }), - updatedAt: timestamp("updated_at", { precision: 6, mode: 'string' }), - createdById: integer("created_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), - updatedById: integer("updated_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), -}, -(table) => { - return { - createdByIdFk: index("strapi_api_token_permissions_created_by_id_fk").on(table.createdById), - updatedByIdFk: index("strapi_api_token_permissions_updated_by_id_fk").on(table.updatedById), - } -}); - -export const strapiTransferTokens = pgTable("strapi_transfer_tokens", { - id: serial("id").primaryKey().notNull(), - name: varchar("name", { length: 255 }), - description: varchar("description", { length: 255 }), - accessKey: varchar("access_key", { length: 255 }), - lastUsedAt: timestamp("last_used_at", { precision: 6, mode: 'string' }), - expiresAt: timestamp("expires_at", { precision: 6, mode: 'string' }), - // You can use { mode: "bigint" } if numbers are exceeding js number limitations - lifespan: bigint("lifespan", { mode: "number" }), - createdAt: timestamp("created_at", { precision: 6, mode: 'string' }), - updatedAt: timestamp("updated_at", { precision: 6, mode: 'string' }), - createdById: integer("created_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), - updatedById: integer("updated_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), -}, -(table) => { - return { - createdByIdFk: index("strapi_transfer_tokens_created_by_id_fk").on(table.createdById), - updatedByIdFk: index("strapi_transfer_tokens_updated_by_id_fk").on(table.updatedById), - } -}); - -export const strapiTransferTokenPermissions = pgTable("strapi_transfer_token_permissions", { - id: serial("id").primaryKey().notNull(), - action: varchar("action", { length: 255 }), - createdAt: timestamp("created_at", { precision: 6, mode: 'string' }), - updatedAt: timestamp("updated_at", { precision: 6, mode: 'string' }), - createdById: integer("created_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), - updatedById: integer("updated_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), -}, -(table) => { - return { - createdByIdFk: index("strapi_transfer_token_permissions_created_by_id_fk").on(table.createdById), - updatedByIdFk: index("strapi_transfer_token_permissions_updated_by_id_fk").on(table.updatedById), - } -}); - -export const files = pgTable("files", { - id: serial("id").primaryKey().notNull(), - name: varchar("name", { length: 255 }), - alternativeText: varchar("alternative_text", { length: 255 }), - caption: varchar("caption", { length: 255 }), - width: integer("width"), - height: integer("height"), - formats: jsonb("formats"), - hash: varchar("hash", { length: 255 }), - ext: varchar("ext", { length: 255 }), - mime: varchar("mime", { length: 255 }), - size: numeric("size", { precision: 10, scale: 2 }), - url: varchar("url", { length: 255 }), - previewUrl: varchar("preview_url", { length: 255 }), - provider: varchar("provider", { length: 255 }), - providerMetadata: jsonb("provider_metadata"), - folderPath: varchar("folder_path", { length: 255 }), - createdAt: timestamp("created_at", { precision: 6, mode: 'string' }), - updatedAt: timestamp("updated_at", { precision: 6, mode: 'string' }), - createdById: integer("created_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), - updatedById: integer("updated_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), -}, -(table) => { - return { - uploadFilesFolderPathIdx: index("upload_files_folder_path_index").on(table.folderPath), - uploadFilesCreatedAtIdx: index("upload_files_created_at_index").on(table.createdAt), - uploadFilesUpdatedAtIdx: index("upload_files_updated_at_index").on(table.updatedAt), - uploadFilesNameIdx: index("upload_files_name_index").on(table.name), - uploadFilesSizeIdx: index("upload_files_size_index").on(table.size), - uploadFilesExtIdx: index("upload_files_ext_index").on(table.ext), - createdByIdFk: index("files_created_by_id_fk").on(table.createdById), - updatedByIdFk: index("files_updated_by_id_fk").on(table.updatedById), - } -}); - -export const uploadFolders = pgTable("upload_folders", { - id: serial("id").primaryKey().notNull(), - name: varchar("name", { length: 255 }), - pathId: integer("path_id"), - path: varchar("path", { length: 255 }), - createdAt: timestamp("created_at", { precision: 6, mode: 'string' }), - updatedAt: timestamp("updated_at", { precision: 6, mode: 'string' }), - createdById: integer("created_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), - updatedById: integer("updated_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), -}, -(table) => { - return { - createdByIdFk: index("upload_folders_created_by_id_fk").on(table.createdById), - updatedByIdFk: index("upload_folders_updated_by_id_fk").on(table.updatedById), - uploadFoldersPathIdIndex: unique("upload_folders_path_id_index").on(table.pathId), - uploadFoldersPathIndex: unique("upload_folders_path_index").on(table.path), - } -}); - -export const strapiReleases = pgTable("strapi_releases", { - id: serial("id").primaryKey().notNull(), - name: varchar("name", { length: 255 }), - releasedAt: timestamp("released_at", { precision: 6, mode: 'string' }), - scheduledAt: timestamp("scheduled_at", { precision: 6, mode: 'string' }), - timezone: varchar("timezone", { length: 255 }), - status: varchar("status", { length: 255 }), - createdAt: timestamp("created_at", { precision: 6, mode: 'string' }), - updatedAt: timestamp("updated_at", { precision: 6, mode: 'string' }), - createdById: integer("created_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), - updatedById: integer("updated_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), -}, -(table) => { - return { - createdByIdFk: index("strapi_releases_created_by_id_fk").on(table.createdById), - updatedByIdFk: index("strapi_releases_updated_by_id_fk").on(table.updatedById), - } -}); - -export const strapiReleaseActions = pgTable("strapi_release_actions", { - id: serial("id").primaryKey().notNull(), - type: varchar("type", { length: 255 }), - targetId: integer("target_id"), - targetType: varchar("target_type", { length: 255 }), - contentType: varchar("content_type", { length: 255 }), - locale: varchar("locale", { length: 255 }), - isEntryValid: boolean("is_entry_valid"), - createdAt: timestamp("created_at", { precision: 6, mode: 'string' }), - updatedAt: timestamp("updated_at", { precision: 6, mode: 'string' }), - createdById: integer("created_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), - updatedById: integer("updated_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), -}, -(table) => { - return { - createdByIdFk: index("strapi_release_actions_created_by_id_fk").on(table.createdById), - updatedByIdFk: index("strapi_release_actions_updated_by_id_fk").on(table.updatedById), - } -}); - -export const i18NLocale = pgTable("i18n_locale", { - id: serial("id").primaryKey().notNull(), - name: varchar("name", { length: 255 }), - code: varchar("code", { length: 255 }), - createdAt: timestamp("created_at", { precision: 6, mode: 'string' }), - updatedAt: timestamp("updated_at", { precision: 6, mode: 'string' }), - createdById: integer("created_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), - updatedById: integer("updated_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), -}, -(table) => { - return { - createdByIdFk: index("i18n_locale_created_by_id_fk").on(table.createdById), - updatedByIdFk: index("i18n_locale_updated_by_id_fk").on(table.updatedById), - } -}); - -export const upPermissions = pgTable("up_permissions", { - id: serial("id").primaryKey().notNull(), - action: varchar("action", { length: 255 }), - createdAt: timestamp("created_at", { precision: 6, mode: 'string' }), - updatedAt: timestamp("updated_at", { precision: 6, mode: 'string' }), - createdById: integer("created_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), - updatedById: integer("updated_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), -}, -(table) => { - return { - createdByIdFk: index("up_permissions_created_by_id_fk").on(table.createdById), - updatedByIdFk: index("up_permissions_updated_by_id_fk").on(table.updatedById), - } -}); - -export const upRoles = pgTable("up_roles", { - id: serial("id").primaryKey().notNull(), - name: varchar("name", { length: 255 }), - description: varchar("description", { length: 255 }), - type: varchar("type", { length: 255 }), - createdAt: timestamp("created_at", { precision: 6, mode: 'string' }), - updatedAt: timestamp("updated_at", { precision: 6, mode: 'string' }), - createdById: integer("created_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), - updatedById: integer("updated_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), -}, -(table) => { - return { - createdByIdFk: index("up_roles_created_by_id_fk").on(table.createdById), - updatedByIdFk: index("up_roles_updated_by_id_fk").on(table.updatedById), - } -}); - -export const upUsers = pgTable("up_users", { - id: serial("id").primaryKey().notNull(), - username: varchar("username", { length: 255 }), - email: varchar("email", { length: 255 }), - provider: varchar("provider", { length: 255 }), - password: varchar("password", { length: 255 }), - resetPasswordToken: varchar("reset_password_token", { length: 255 }), - confirmationToken: varchar("confirmation_token", { length: 255 }), - confirmed: boolean("confirmed"), - blocked: boolean("blocked"), - createdAt: timestamp("created_at", { precision: 6, mode: 'string' }), - updatedAt: timestamp("updated_at", { precision: 6, mode: 'string' }), - createdById: integer("created_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), - updatedById: integer("updated_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), -}, -(table) => { - return { - createdByIdFk: index("up_users_created_by_id_fk").on(table.createdById), - updatedByIdFk: index("up_users_updated_by_id_fk").on(table.updatedById), - } -}); - -export const applicationMetadatas = pgTable("application_metadatas", { - id: serial("id").primaryKey().notNull(), - version: varchar("version", { length: 255 }), - versionUpdatedAt: date("version_updated_at"), - createdAt: timestamp("created_at", { precision: 6, mode: 'string' }), - updatedAt: timestamp("updated_at", { precision: 6, mode: 'string' }), - publishedAt: timestamp("published_at", { precision: 6, mode: 'string' }), - createdById: integer("created_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), - updatedById: integer("updated_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), -}, -(table) => { - return { - createdByIdFk: index("application_metadatas_created_by_id_fk").on(table.createdById), - updatedByIdFk: index("application_metadatas_updated_by_id_fk").on(table.updatedById), - } -}); - -export const methods = pgTable("methods", { - id: serial("id").primaryKey().notNull(), - title: varchar("title", { length: 255 }), - description: text("description"), - icon: varchar("icon", { length: 255 }), - href: varchar("href", { length: 255 }), - tag: varchar("tag", { length: 255 }), - createdAt: timestamp("created_at", { precision: 6, mode: 'string' }), - updatedAt: timestamp("updated_at", { precision: 6, mode: 'string' }), - publishedAt: timestamp("published_at", { precision: 6, mode: 'string' }), - createdById: integer("created_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), - updatedById: integer("updated_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), - locale: varchar("locale", { length: 255 }), -}, -(table) => { - return { - createdByIdFk: index("methods_created_by_id_fk").on(table.createdById), - updatedByIdFk: index("methods_updated_by_id_fk").on(table.updatedById), - } -}); - -export const pages = pgTable("pages", { - id: serial("id").primaryKey().notNull(), - name: varchar("name", { length: 255 }), - slug: varchar("slug", { length: 255 }), - content: text("content"), - order: integer("order"), - cmsPage: boolean("cms_page"), - showInNav: boolean("show_in_nav"), - openInNewTab: boolean("open_in_new_tab"), - createdAt: timestamp("created_at", { precision: 6, mode: 'string' }), - updatedAt: timestamp("updated_at", { precision: 6, mode: 'string' }), - publishedAt: timestamp("published_at", { precision: 6, mode: 'string' }), - createdById: integer("created_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), - updatedById: integer("updated_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), -}, -(table) => { - return { - createdByIdFk: index("pages_created_by_id_fk").on(table.createdById), - updatedByIdFk: index("pages_updated_by_id_fk").on(table.updatedById), - } -}); - -export const publishers = pgTable("publishers", { - id: serial("id").primaryKey().notNull(), - owner: varchar("owner", { length: 255 }), - repo: varchar("repo", { length: 255 }), - secret: varchar("secret", { length: 255 }), - name: varchar("name", { length: 255 }), - createdAt: timestamp("created_at", { precision: 6, mode: 'string' }), - updatedAt: timestamp("updated_at", { precision: 6, mode: 'string' }), - publishedAt: timestamp("published_at", { precision: 6, mode: 'string' }), - createdById: integer("created_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), - updatedById: integer("updated_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), -}, -(table) => { - return { - createdByIdFk: index("publishers_created_by_id_fk").on(table.createdById), - updatedByIdFk: index("publishers_updated_by_id_fk").on(table.updatedById), - } -}); - -export const adminPermissionsRoleLinks = pgTable("admin_permissions_role_links", { - id: serial("id").primaryKey().notNull(), - permissionId: integer("permission_id").references(() => adminPermissions.id, { onDelete: "cascade" } ), - roleId: integer("role_id").references(() => adminRoles.id, { onDelete: "cascade" } ), - permissionOrder: doublePrecision("permission_order"), -}, -(table) => { - return { - fk: index("admin_permissions_role_links_fk").on(table.permissionId), - invFk: index("admin_permissions_role_links_inv_fk").on(table.roleId), - orderInvFk: index("admin_permissions_role_links_order_inv_fk").on(table.permissionOrder), - adminPermissionsRoleLinksUnique: unique("admin_permissions_role_links_unique").on(table.permissionId, table.roleId), - } -}); - -export const adminUsersRolesLinks = pgTable("admin_users_roles_links", { - id: serial("id").primaryKey().notNull(), - userId: integer("user_id").references(() => adminUsers.id, { onDelete: "cascade" } ), - roleId: integer("role_id").references(() => adminRoles.id, { onDelete: "cascade" } ), - roleOrder: doublePrecision("role_order"), - userOrder: doublePrecision("user_order"), -}, -(table) => { - return { - fk: index("admin_users_roles_links_fk").on(table.userId), - invFk: index("admin_users_roles_links_inv_fk").on(table.roleId), - orderFk: index("admin_users_roles_links_order_fk").on(table.roleOrder), - orderInvFk: index("admin_users_roles_links_order_inv_fk").on(table.userOrder), - adminUsersRolesLinksUnique: unique("admin_users_roles_links_unique").on(table.userId, table.roleId), - } -}); - -export const strapiApiTokenPermissionsTokenLinks = pgTable("strapi_api_token_permissions_token_links", { - id: serial("id").primaryKey().notNull(), - apiTokenPermissionId: integer("api_token_permission_id").references(() => strapiApiTokenPermissions.id, { onDelete: "cascade" } ), - apiTokenId: integer("api_token_id").references(() => strapiApiTokens.id, { onDelete: "cascade" } ), - apiTokenPermissionOrder: doublePrecision("api_token_permission_order"), -}, -(table) => { - return { - fk: index("strapi_api_token_permissions_token_links_fk").on(table.apiTokenPermissionId), - invFk: index("strapi_api_token_permissions_token_links_inv_fk").on(table.apiTokenId), - orderInvFk: index("strapi_api_token_permissions_token_links_order_inv_fk").on(table.apiTokenPermissionOrder), - strapiApiTokenPermissionsTokenLinksUnique: unique("strapi_api_token_permissions_token_links_unique").on(table.apiTokenPermissionId, table.apiTokenId), - } -}); - -export const strapiTransferTokenPermissionsTokenLinks = pgTable("strapi_transfer_token_permissions_token_links", { - id: serial("id").primaryKey().notNull(), - transferTokenPermissionId: integer("transfer_token_permission_id").references(() => strapiTransferTokenPermissions.id, { onDelete: "cascade" } ), - transferTokenId: integer("transfer_token_id").references(() => strapiTransferTokens.id, { onDelete: "cascade" } ), - transferTokenPermissionOrder: doublePrecision("transfer_token_permission_order"), -}, -(table) => { - return { - fk: index("strapi_transfer_token_permissions_token_links_fk").on(table.transferTokenPermissionId), - invFk: index("strapi_transfer_token_permissions_token_links_inv_fk").on(table.transferTokenId), - orderInvFk: index("strapi_transfer_token_permissions_token_links_order_inv_fk").on(table.transferTokenPermissionOrder), - strapiTransferTokenPermissionsTokenLinksUnique: unique("strapi_transfer_token_permissions_token_links_unique").on(table.transferTokenPermissionId, table.transferTokenId), - } -}); - -export const filesRelatedMorphs = pgTable("files_related_morphs", { - id: serial("id").primaryKey().notNull(), - fileId: integer("file_id").references(() => files.id, { onDelete: "cascade" } ), - relatedId: integer("related_id"), - relatedType: varchar("related_type", { length: 255 }), - field: varchar("field", { length: 255 }), - order: doublePrecision("order"), -}, -(table) => { - return { - fk: index("files_related_morphs_fk").on(table.fileId), - orderIdx: index().on(table.order), - idColumnIdx: index("files_related_morphs_id_column_index").on(table.relatedId), - } -}); - -export const filesFolderLinks = pgTable("files_folder_links", { - id: serial("id").primaryKey().notNull(), - fileId: integer("file_id").references(() => files.id, { onDelete: "cascade" } ), - folderId: integer("folder_id").references(() => uploadFolders.id, { onDelete: "cascade" } ), - fileOrder: doublePrecision("file_order"), -}, -(table) => { - return { - fk: index("files_folder_links_fk").on(table.fileId), - invFk: index("files_folder_links_inv_fk").on(table.folderId), - orderInvFk: index("files_folder_links_order_inv_fk").on(table.fileOrder), - filesFolderLinksUnique: unique("files_folder_links_unique").on(table.fileId, table.folderId), - } -}); - -export const uploadFoldersParentLinks = pgTable("upload_folders_parent_links", { - id: serial("id").primaryKey().notNull(), - folderId: integer("folder_id").references(() => uploadFolders.id, { onDelete: "cascade" } ), - invFolderId: integer("inv_folder_id").references(() => uploadFolders.id, { onDelete: "cascade" } ), - folderOrder: doublePrecision("folder_order"), -}, -(table) => { - return { - fk: index("upload_folders_parent_links_fk").on(table.folderId), - invFk: index("upload_folders_parent_links_inv_fk").on(table.invFolderId), - orderInvFk: index("upload_folders_parent_links_order_inv_fk").on(table.folderOrder), - uploadFoldersParentLinksUnique: unique("upload_folders_parent_links_unique").on(table.folderId, table.invFolderId), - } -}); - -export const strapiReleaseActionsReleaseLinks = pgTable("strapi_release_actions_release_links", { - id: serial("id").primaryKey().notNull(), - releaseActionId: integer("release_action_id").references(() => strapiReleaseActions.id, { onDelete: "cascade" } ), - releaseId: integer("release_id").references(() => strapiReleases.id, { onDelete: "cascade" } ), - releaseActionOrder: doublePrecision("release_action_order"), -}, -(table) => { - return { - fk: index("strapi_release_actions_release_links_fk").on(table.releaseActionId), - invFk: index("strapi_release_actions_release_links_inv_fk").on(table.releaseId), - orderInvFk: index("strapi_release_actions_release_links_order_inv_fk").on(table.releaseActionOrder), - strapiReleaseActionsReleaseLinksUnique: unique("strapi_release_actions_release_links_unique").on(table.releaseActionId, table.releaseId), - } -}); - -export const upPermissionsRoleLinks = pgTable("up_permissions_role_links", { - id: serial("id").primaryKey().notNull(), - permissionId: integer("permission_id").references(() => upPermissions.id, { onDelete: "cascade" } ), - roleId: integer("role_id").references(() => upRoles.id, { onDelete: "cascade" } ), - permissionOrder: doublePrecision("permission_order"), -}, -(table) => { - return { - fk: index("up_permissions_role_links_fk").on(table.permissionId), - invFk: index("up_permissions_role_links_inv_fk").on(table.roleId), - orderInvFk: index("up_permissions_role_links_order_inv_fk").on(table.permissionOrder), - upPermissionsRoleLinksUnique: unique("up_permissions_role_links_unique").on(table.permissionId, table.roleId), - } -}); - -export const upUsersRoleLinks = pgTable("up_users_role_links", { - id: serial("id").primaryKey().notNull(), - userId: integer("user_id").references(() => upUsers.id, { onDelete: "cascade" } ), - roleId: integer("role_id").references(() => upRoles.id, { onDelete: "cascade" } ), - userOrder: doublePrecision("user_order"), -}, -(table) => { - return { - fk: index("up_users_role_links_fk").on(table.userId), - invFk: index("up_users_role_links_inv_fk").on(table.roleId), - orderInvFk: index("up_users_role_links_order_inv_fk").on(table.userOrder), - upUsersRoleLinksUnique: unique("up_users_role_links_unique").on(table.userId, table.roleId), - } -}); - -export const methodsLocalizationsLinks = pgTable("methods_localizations_links", { - id: serial("id").primaryKey().notNull(), - methodId: integer("method_id").references(() => methods.id, { onDelete: "cascade" } ), - invMethodId: integer("inv_method_id").references(() => methods.id, { onDelete: "cascade" } ), - methodOrder: doublePrecision("method_order"), -}, -(table) => { - return { - fk: index("methods_localizations_links_fk").on(table.methodId), - invFk: index("methods_localizations_links_inv_fk").on(table.invMethodId), - orderFk: index("methods_localizations_links_order_fk").on(table.methodOrder), - methodsLocalizationsLinksUnique: unique("methods_localizations_links_unique").on(table.methodId, table.invMethodId), - } -}); - -export const terms = pgTable("terms", { - id: serial("id").primaryKey().notNull(), - slug: varchar("slug", { length: 255 }), - createdAt: timestamp("created_at", { precision: 6, mode: 'string' }), - updatedAt: timestamp("updated_at", { precision: 6, mode: 'string' }), - publishedAt: timestamp("published_at", { precision: 6, mode: 'string' }), - createdById: integer("created_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), - updatedById: integer("updated_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), -}, -(table) => { - return { - createdByIdFk: index("terms_created_by_id_fk").on(table.createdById), - updatedByIdFk: index("terms_updated_by_id_fk").on(table.updatedById), - } -}); - -export const events = pgTable("events", { - id: serial("id").primaryKey().notNull(), - title: varchar("title", { length: 255 }).notNull(), - intro: text("intro").notNull(), - start: timestamp("start", { precision: 6, mode: 'string' }).notNull(), - end: timestamp("end", { precision: 6, mode: 'string' }).notNull(), - subject: varchar("subject", { length: 255 }).notNull(), - address: varchar("address", { length: 255 }).notNull(), - content: text("content").notNull(), - slug: varchar("slug", { length: 255 }).notNull(), - addressName: varchar("address_name", { length: 255 }).notNull(), - eventbrite: text("eventbrite"), - eventbriteTitle: varchar("eventbrite_title", { length: 255 }), - createdAt: timestamp("created_at", { precision: 6, mode: 'string' }), - updatedAt: timestamp("updated_at", { precision: 6, mode: 'string' }), - publishedAt: timestamp("published_at", { precision: 6, mode: 'string' }), - createdById: integer("created_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), - updatedById: integer("updated_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), - report: text("report"), -}, -(table) => { - return { - createdByIdFk: index("events_created_by_id_fk").on(table.createdById), - updatedByIdFk: index("events_updated_by_id_fk").on(table.updatedById), - eventsSlugUnique: unique("events_slug_unique").on(table.slug), - } -}); - -export const blogArticles = pgTable("blog_articles", { - id: serial("id").primaryKey().notNull(), - title: varchar("title", { length: 255 }), - category: varchar("category", { length: 255 }), - content: text("content"), - description: text("description"), - createdAt: timestamp("created_at", { precision: 6, mode: 'string' }), - updatedAt: timestamp("updated_at", { precision: 6, mode: 'string' }), - publishedAt: timestamp("published_at", { precision: 6, mode: 'string' }), - createdById: integer("created_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), - updatedById: integer("updated_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), - source: text("source"), -}, -(table) => { - return { - createdByIdFk: index("blog_articles_created_by_id_fk").on(table.createdById), - updatedByIdFk: index("blog_articles_updated_by_id_fk").on(table.updatedById), - } -}); - -export const publications = pgTable("publications", { - id: serial("id").primaryKey().notNull(), - title: varchar("title", { length: 255 }), - summary: text("summary"), - content: text("content"), - tags: text("tags"), - slug: varchar("slug", { length: 255 }), - authors: text("authors"), - location: varchar("location", { length: 255 }), - createdAt: timestamp("created_at", { precision: 6, mode: 'string' }), - updatedAt: timestamp("updated_at", { precision: 6, mode: 'string' }), - publishedAt: timestamp("published_at", { precision: 6, mode: 'string' }), - createdById: integer("created_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), - updatedById: integer("updated_by_id").references(() => adminUsers.id, { onDelete: "set null" } ), - cite: text("cite"), - originalSource: varchar("original_source", { length: 255 }), - publicationDate: date("publication_date"), -}, -(table) => { - return { - createdByIdFk: index("publications_created_by_id_fk").on(table.createdById), - updatedByIdFk: index("publications_updated_by_id_fk").on(table.updatedById), - publicationsSlugUnique: unique("publications_slug_unique").on(table.slug), - } -}); \ No newline at end of file +import { + pgTable, + serial, + varchar, + timestamp, + json, + text, + jsonb, + boolean, + index, + foreignKey, + integer, + bigint, + numeric, + unique, + date, + doublePrecision, +} from 'drizzle-orm/pg-core'; +import { sql } from 'drizzle-orm'; + +export const strapiMigrations = pgTable('strapi_migrations', { + id: serial('id').primaryKey().notNull(), + name: varchar('name', { length: 255 }), + time: timestamp('time', { mode: 'string' }), +}); + +export const strapiDatabaseSchema = pgTable('strapi_database_schema', { + id: serial('id').primaryKey().notNull(), + schema: json('schema'), + time: timestamp('time', { mode: 'string' }), + hash: varchar('hash', { length: 255 }), +}); + +export const strapiCoreStoreSettings = pgTable('strapi_core_store_settings', { + id: serial('id').primaryKey().notNull(), + key: varchar('key', { length: 255 }), + value: text('value'), + type: varchar('type', { length: 255 }), + environment: varchar('environment', { length: 255 }), + tag: varchar('tag', { length: 255 }), +}); + +export const strapiWebhooks = pgTable('strapi_webhooks', { + id: serial('id').primaryKey().notNull(), + name: varchar('name', { length: 255 }), + url: text('url'), + headers: jsonb('headers'), + events: jsonb('events'), + enabled: boolean('enabled'), +}); + +export const adminUsers = pgTable( + 'admin_users', + { + id: serial('id').primaryKey().notNull(), + firstname: varchar('firstname', { length: 255 }), + lastname: varchar('lastname', { length: 255 }), + username: varchar('username', { length: 255 }), + email: varchar('email', { length: 255 }), + password: varchar('password', { length: 255 }), + resetPasswordToken: varchar('reset_password_token', { length: 255 }), + registrationToken: varchar('registration_token', { length: 255 }), + isActive: boolean('is_active'), + blocked: boolean('blocked'), + preferedLanguage: varchar('prefered_language', { length: 255 }), + createdAt: timestamp('created_at', { precision: 6, mode: 'string' }), + updatedAt: timestamp('updated_at', { precision: 6, mode: 'string' }), + createdById: integer('created_by_id'), + updatedById: integer('updated_by_id'), + }, + (table) => { + return { + createdByIdFk: index('admin_users_created_by_id_fk').on(table.createdById), + updatedByIdFk: index('admin_users_updated_by_id_fk').on(table.updatedById), + adminUsersCreatedByIdFk: foreignKey({ + columns: [table.createdById], + foreignColumns: [table.id], + name: 'admin_users_created_by_id_fk', + }).onDelete('set null'), + adminUsersUpdatedByIdFk: foreignKey({ + columns: [table.updatedById], + foreignColumns: [table.id], + name: 'admin_users_updated_by_id_fk', + }).onDelete('set null'), + }; + } +); + +export const adminPermissions = pgTable( + 'admin_permissions', + { + id: serial('id').primaryKey().notNull(), + action: varchar('action', { length: 255 }), + actionParameters: jsonb('action_parameters'), + subject: varchar('subject', { length: 255 }), + properties: jsonb('properties'), + conditions: jsonb('conditions'), + createdAt: timestamp('created_at', { precision: 6, mode: 'string' }), + updatedAt: timestamp('updated_at', { precision: 6, mode: 'string' }), + createdById: integer('created_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + updatedById: integer('updated_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + }, + (table) => { + return { + createdByIdFk: index('admin_permissions_created_by_id_fk').on(table.createdById), + updatedByIdFk: index('admin_permissions_updated_by_id_fk').on(table.updatedById), + }; + } +); + +export const adminRoles = pgTable( + 'admin_roles', + { + id: serial('id').primaryKey().notNull(), + name: varchar('name', { length: 255 }), + code: varchar('code', { length: 255 }), + description: varchar('description', { length: 255 }), + createdAt: timestamp('created_at', { precision: 6, mode: 'string' }), + updatedAt: timestamp('updated_at', { precision: 6, mode: 'string' }), + createdById: integer('created_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + updatedById: integer('updated_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + }, + (table) => { + return { + createdByIdFk: index('admin_roles_created_by_id_fk').on(table.createdById), + updatedByIdFk: index('admin_roles_updated_by_id_fk').on(table.updatedById), + }; + } +); + +export const strapiApiTokens = pgTable( + 'strapi_api_tokens', + { + id: serial('id').primaryKey().notNull(), + name: varchar('name', { length: 255 }), + description: varchar('description', { length: 255 }), + type: varchar('type', { length: 255 }), + accessKey: varchar('access_key', { length: 255 }), + lastUsedAt: timestamp('last_used_at', { precision: 6, mode: 'string' }), + expiresAt: timestamp('expires_at', { precision: 6, mode: 'string' }), + // You can use { mode: "bigint" } if numbers are exceeding js number limitations + lifespan: bigint('lifespan', { mode: 'number' }), + createdAt: timestamp('created_at', { precision: 6, mode: 'string' }), + updatedAt: timestamp('updated_at', { precision: 6, mode: 'string' }), + createdById: integer('created_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + updatedById: integer('updated_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + }, + (table) => { + return { + createdByIdFk: index('strapi_api_tokens_created_by_id_fk').on(table.createdById), + updatedByIdFk: index('strapi_api_tokens_updated_by_id_fk').on(table.updatedById), + }; + } +); + +export const strapiApiTokenPermissions = pgTable( + 'strapi_api_token_permissions', + { + id: serial('id').primaryKey().notNull(), + action: varchar('action', { length: 255 }), + createdAt: timestamp('created_at', { precision: 6, mode: 'string' }), + updatedAt: timestamp('updated_at', { precision: 6, mode: 'string' }), + createdById: integer('created_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + updatedById: integer('updated_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + }, + (table) => { + return { + createdByIdFk: index('strapi_api_token_permissions_created_by_id_fk').on(table.createdById), + updatedByIdFk: index('strapi_api_token_permissions_updated_by_id_fk').on(table.updatedById), + }; + } +); + +export const strapiTransferTokens = pgTable( + 'strapi_transfer_tokens', + { + id: serial('id').primaryKey().notNull(), + name: varchar('name', { length: 255 }), + description: varchar('description', { length: 255 }), + accessKey: varchar('access_key', { length: 255 }), + lastUsedAt: timestamp('last_used_at', { precision: 6, mode: 'string' }), + expiresAt: timestamp('expires_at', { precision: 6, mode: 'string' }), + // You can use { mode: "bigint" } if numbers are exceeding js number limitations + lifespan: bigint('lifespan', { mode: 'number' }), + createdAt: timestamp('created_at', { precision: 6, mode: 'string' }), + updatedAt: timestamp('updated_at', { precision: 6, mode: 'string' }), + createdById: integer('created_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + updatedById: integer('updated_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + }, + (table) => { + return { + createdByIdFk: index('strapi_transfer_tokens_created_by_id_fk').on(table.createdById), + updatedByIdFk: index('strapi_transfer_tokens_updated_by_id_fk').on(table.updatedById), + }; + } +); + +export const strapiTransferTokenPermissions = pgTable( + 'strapi_transfer_token_permissions', + { + id: serial('id').primaryKey().notNull(), + action: varchar('action', { length: 255 }), + createdAt: timestamp('created_at', { precision: 6, mode: 'string' }), + updatedAt: timestamp('updated_at', { precision: 6, mode: 'string' }), + createdById: integer('created_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + updatedById: integer('updated_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + }, + (table) => { + return { + createdByIdFk: index('strapi_transfer_token_permissions_created_by_id_fk').on(table.createdById), + updatedByIdFk: index('strapi_transfer_token_permissions_updated_by_id_fk').on(table.updatedById), + }; + } +); + +export const files = pgTable( + 'files', + { + id: serial('id').primaryKey().notNull(), + name: varchar('name', { length: 255 }), + alternativeText: varchar('alternative_text', { length: 255 }), + caption: varchar('caption', { length: 255 }), + width: integer('width'), + height: integer('height'), + formats: jsonb('formats'), + hash: varchar('hash', { length: 255 }), + ext: varchar('ext', { length: 255 }), + mime: varchar('mime', { length: 255 }), + size: numeric('size', { precision: 10, scale: 2 }), + url: varchar('url', { length: 255 }), + previewUrl: varchar('preview_url', { length: 255 }), + provider: varchar('provider', { length: 255 }), + providerMetadata: jsonb('provider_metadata'), + folderPath: varchar('folder_path', { length: 255 }), + createdAt: timestamp('created_at', { precision: 6, mode: 'string' }), + updatedAt: timestamp('updated_at', { precision: 6, mode: 'string' }), + createdById: integer('created_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + updatedById: integer('updated_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + }, + (table) => { + return { + uploadFilesFolderPathIdx: index('upload_files_folder_path_index').on(table.folderPath), + uploadFilesCreatedAtIdx: index('upload_files_created_at_index').on(table.createdAt), + uploadFilesUpdatedAtIdx: index('upload_files_updated_at_index').on(table.updatedAt), + uploadFilesNameIdx: index('upload_files_name_index').on(table.name), + uploadFilesSizeIdx: index('upload_files_size_index').on(table.size), + uploadFilesExtIdx: index('upload_files_ext_index').on(table.ext), + createdByIdFk: index('files_created_by_id_fk').on(table.createdById), + updatedByIdFk: index('files_updated_by_id_fk').on(table.updatedById), + }; + } +); + +export const uploadFolders = pgTable( + 'upload_folders', + { + id: serial('id').primaryKey().notNull(), + name: varchar('name', { length: 255 }), + pathId: integer('path_id'), + path: varchar('path', { length: 255 }), + createdAt: timestamp('created_at', { precision: 6, mode: 'string' }), + updatedAt: timestamp('updated_at', { precision: 6, mode: 'string' }), + createdById: integer('created_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + updatedById: integer('updated_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + }, + (table) => { + return { + createdByIdFk: index('upload_folders_created_by_id_fk').on(table.createdById), + updatedByIdFk: index('upload_folders_updated_by_id_fk').on(table.updatedById), + uploadFoldersPathIdIndex: unique('upload_folders_path_id_index').on(table.pathId), + uploadFoldersPathIndex: unique('upload_folders_path_index').on(table.path), + }; + } +); + +export const strapiReleases = pgTable( + 'strapi_releases', + { + id: serial('id').primaryKey().notNull(), + name: varchar('name', { length: 255 }), + releasedAt: timestamp('released_at', { precision: 6, mode: 'string' }), + scheduledAt: timestamp('scheduled_at', { precision: 6, mode: 'string' }), + timezone: varchar('timezone', { length: 255 }), + status: varchar('status', { length: 255 }), + createdAt: timestamp('created_at', { precision: 6, mode: 'string' }), + updatedAt: timestamp('updated_at', { precision: 6, mode: 'string' }), + createdById: integer('created_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + updatedById: integer('updated_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + }, + (table) => { + return { + createdByIdFk: index('strapi_releases_created_by_id_fk').on(table.createdById), + updatedByIdFk: index('strapi_releases_updated_by_id_fk').on(table.updatedById), + }; + } +); + +export const strapiReleaseActions = pgTable( + 'strapi_release_actions', + { + id: serial('id').primaryKey().notNull(), + type: varchar('type', { length: 255 }), + targetId: integer('target_id'), + targetType: varchar('target_type', { length: 255 }), + contentType: varchar('content_type', { length: 255 }), + locale: varchar('locale', { length: 255 }), + isEntryValid: boolean('is_entry_valid'), + createdAt: timestamp('created_at', { precision: 6, mode: 'string' }), + updatedAt: timestamp('updated_at', { precision: 6, mode: 'string' }), + createdById: integer('created_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + updatedById: integer('updated_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + }, + (table) => { + return { + createdByIdFk: index('strapi_release_actions_created_by_id_fk').on(table.createdById), + updatedByIdFk: index('strapi_release_actions_updated_by_id_fk').on(table.updatedById), + }; + } +); + +export const i18NLocale = pgTable( + 'i18n_locale', + { + id: serial('id').primaryKey().notNull(), + name: varchar('name', { length: 255 }), + code: varchar('code', { length: 255 }), + createdAt: timestamp('created_at', { precision: 6, mode: 'string' }), + updatedAt: timestamp('updated_at', { precision: 6, mode: 'string' }), + createdById: integer('created_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + updatedById: integer('updated_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + }, + (table) => { + return { + createdByIdFk: index('i18n_locale_created_by_id_fk').on(table.createdById), + updatedByIdFk: index('i18n_locale_updated_by_id_fk').on(table.updatedById), + }; + } +); + +export const upPermissions = pgTable( + 'up_permissions', + { + id: serial('id').primaryKey().notNull(), + action: varchar('action', { length: 255 }), + createdAt: timestamp('created_at', { precision: 6, mode: 'string' }), + updatedAt: timestamp('updated_at', { precision: 6, mode: 'string' }), + createdById: integer('created_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + updatedById: integer('updated_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + }, + (table) => { + return { + createdByIdFk: index('up_permissions_created_by_id_fk').on(table.createdById), + updatedByIdFk: index('up_permissions_updated_by_id_fk').on(table.updatedById), + }; + } +); + +export const upRoles = pgTable( + 'up_roles', + { + id: serial('id').primaryKey().notNull(), + name: varchar('name', { length: 255 }), + description: varchar('description', { length: 255 }), + type: varchar('type', { length: 255 }), + createdAt: timestamp('created_at', { precision: 6, mode: 'string' }), + updatedAt: timestamp('updated_at', { precision: 6, mode: 'string' }), + createdById: integer('created_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + updatedById: integer('updated_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + }, + (table) => { + return { + createdByIdFk: index('up_roles_created_by_id_fk').on(table.createdById), + updatedByIdFk: index('up_roles_updated_by_id_fk').on(table.updatedById), + }; + } +); + +export const upUsers = pgTable( + 'up_users', + { + id: serial('id').primaryKey().notNull(), + username: varchar('username', { length: 255 }), + email: varchar('email', { length: 255 }), + provider: varchar('provider', { length: 255 }), + password: varchar('password', { length: 255 }), + resetPasswordToken: varchar('reset_password_token', { length: 255 }), + confirmationToken: varchar('confirmation_token', { length: 255 }), + confirmed: boolean('confirmed'), + blocked: boolean('blocked'), + createdAt: timestamp('created_at', { precision: 6, mode: 'string' }), + updatedAt: timestamp('updated_at', { precision: 6, mode: 'string' }), + createdById: integer('created_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + updatedById: integer('updated_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + }, + (table) => { + return { + createdByIdFk: index('up_users_created_by_id_fk').on(table.createdById), + updatedByIdFk: index('up_users_updated_by_id_fk').on(table.updatedById), + }; + } +); + +export const applicationMetadatas = pgTable( + 'application_metadatas', + { + id: serial('id').primaryKey().notNull(), + version: varchar('version', { length: 255 }), + versionUpdatedAt: date('version_updated_at'), + createdAt: timestamp('created_at', { precision: 6, mode: 'string' }), + updatedAt: timestamp('updated_at', { precision: 6, mode: 'string' }), + publishedAt: timestamp('published_at', { precision: 6, mode: 'string' }), + createdById: integer('created_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + updatedById: integer('updated_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + }, + (table) => { + return { + createdByIdFk: index('application_metadatas_created_by_id_fk').on(table.createdById), + updatedByIdFk: index('application_metadatas_updated_by_id_fk').on(table.updatedById), + }; + } +); + +export const methods = pgTable( + 'methods', + { + id: serial('id').primaryKey().notNull(), + title: varchar('title', { length: 255 }), + description: text('description'), + icon: varchar('icon', { length: 255 }), + href: varchar('href', { length: 255 }), + tag: varchar('tag', { length: 255 }), + createdAt: timestamp('created_at', { precision: 6, mode: 'string' }), + updatedAt: timestamp('updated_at', { precision: 6, mode: 'string' }), + publishedAt: timestamp('published_at', { precision: 6, mode: 'string' }), + createdById: integer('created_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + updatedById: integer('updated_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + locale: varchar('locale', { length: 255 }), + }, + (table) => { + return { + createdByIdFk: index('methods_created_by_id_fk').on(table.createdById), + updatedByIdFk: index('methods_updated_by_id_fk').on(table.updatedById), + }; + } +); + +export const pages = pgTable( + 'pages', + { + id: serial('id').primaryKey().notNull(), + name: varchar('name', { length: 255 }), + slug: varchar('slug', { length: 255 }), + content: text('content'), + order: integer('order'), + cmsPage: boolean('cms_page'), + showInNav: boolean('show_in_nav'), + openInNewTab: boolean('open_in_new_tab'), + createdAt: timestamp('created_at', { precision: 6, mode: 'string' }), + updatedAt: timestamp('updated_at', { precision: 6, mode: 'string' }), + publishedAt: timestamp('published_at', { precision: 6, mode: 'string' }), + createdById: integer('created_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + updatedById: integer('updated_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + }, + (table) => { + return { + createdByIdFk: index('pages_created_by_id_fk').on(table.createdById), + updatedByIdFk: index('pages_updated_by_id_fk').on(table.updatedById), + }; + } +); + +export const publishers = pgTable( + 'publishers', + { + id: serial('id').primaryKey().notNull(), + owner: varchar('owner', { length: 255 }), + repo: varchar('repo', { length: 255 }), + secret: varchar('secret', { length: 255 }), + name: varchar('name', { length: 255 }), + createdAt: timestamp('created_at', { precision: 6, mode: 'string' }), + updatedAt: timestamp('updated_at', { precision: 6, mode: 'string' }), + publishedAt: timestamp('published_at', { precision: 6, mode: 'string' }), + createdById: integer('created_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + updatedById: integer('updated_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + }, + (table) => { + return { + createdByIdFk: index('publishers_created_by_id_fk').on(table.createdById), + updatedByIdFk: index('publishers_updated_by_id_fk').on(table.updatedById), + }; + } +); + +export const adminPermissionsRoleLinks = pgTable( + 'admin_permissions_role_links', + { + id: serial('id').primaryKey().notNull(), + permissionId: integer('permission_id').references(() => adminPermissions.id, { onDelete: 'cascade' }), + roleId: integer('role_id').references(() => adminRoles.id, { onDelete: 'cascade' }), + permissionOrder: doublePrecision('permission_order'), + }, + (table) => { + return { + fk: index('admin_permissions_role_links_fk').on(table.permissionId), + invFk: index('admin_permissions_role_links_inv_fk').on(table.roleId), + orderInvFk: index('admin_permissions_role_links_order_inv_fk').on(table.permissionOrder), + adminPermissionsRoleLinksUnique: unique('admin_permissions_role_links_unique').on( + table.permissionId, + table.roleId + ), + }; + } +); + +export const adminUsersRolesLinks = pgTable( + 'admin_users_roles_links', + { + id: serial('id').primaryKey().notNull(), + userId: integer('user_id').references(() => adminUsers.id, { onDelete: 'cascade' }), + roleId: integer('role_id').references(() => adminRoles.id, { onDelete: 'cascade' }), + roleOrder: doublePrecision('role_order'), + userOrder: doublePrecision('user_order'), + }, + (table) => { + return { + fk: index('admin_users_roles_links_fk').on(table.userId), + invFk: index('admin_users_roles_links_inv_fk').on(table.roleId), + orderFk: index('admin_users_roles_links_order_fk').on(table.roleOrder), + orderInvFk: index('admin_users_roles_links_order_inv_fk').on(table.userOrder), + adminUsersRolesLinksUnique: unique('admin_users_roles_links_unique').on(table.userId, table.roleId), + }; + } +); + +export const strapiApiTokenPermissionsTokenLinks = pgTable( + 'strapi_api_token_permissions_token_links', + { + id: serial('id').primaryKey().notNull(), + apiTokenPermissionId: integer('api_token_permission_id').references(() => strapiApiTokenPermissions.id, { + onDelete: 'cascade', + }), + apiTokenId: integer('api_token_id').references(() => strapiApiTokens.id, { onDelete: 'cascade' }), + apiTokenPermissionOrder: doublePrecision('api_token_permission_order'), + }, + (table) => { + return { + fk: index('strapi_api_token_permissions_token_links_fk').on(table.apiTokenPermissionId), + invFk: index('strapi_api_token_permissions_token_links_inv_fk').on(table.apiTokenId), + orderInvFk: index('strapi_api_token_permissions_token_links_order_inv_fk').on(table.apiTokenPermissionOrder), + strapiApiTokenPermissionsTokenLinksUnique: unique('strapi_api_token_permissions_token_links_unique').on( + table.apiTokenPermissionId, + table.apiTokenId + ), + }; + } +); + +export const strapiTransferTokenPermissionsTokenLinks = pgTable( + 'strapi_transfer_token_permissions_token_links', + { + id: serial('id').primaryKey().notNull(), + transferTokenPermissionId: integer('transfer_token_permission_id').references( + () => strapiTransferTokenPermissions.id, + { onDelete: 'cascade' } + ), + transferTokenId: integer('transfer_token_id').references(() => strapiTransferTokens.id, { onDelete: 'cascade' }), + transferTokenPermissionOrder: doublePrecision('transfer_token_permission_order'), + }, + (table) => { + return { + fk: index('strapi_transfer_token_permissions_token_links_fk').on(table.transferTokenPermissionId), + invFk: index('strapi_transfer_token_permissions_token_links_inv_fk').on(table.transferTokenId), + orderInvFk: index('strapi_transfer_token_permissions_token_links_order_inv_fk').on( + table.transferTokenPermissionOrder + ), + strapiTransferTokenPermissionsTokenLinksUnique: unique('strapi_transfer_token_permissions_token_links_unique').on( + table.transferTokenPermissionId, + table.transferTokenId + ), + }; + } +); + +export const filesRelatedMorphs = pgTable( + 'files_related_morphs', + { + id: serial('id').primaryKey().notNull(), + fileId: integer('file_id').references(() => files.id, { onDelete: 'cascade' }), + relatedId: integer('related_id'), + relatedType: varchar('related_type', { length: 255 }), + field: varchar('field', { length: 255 }), + order: doublePrecision('order'), + }, + (table) => { + return { + fk: index('files_related_morphs_fk').on(table.fileId), + orderIdx: index().on(table.order), + idColumnIdx: index('files_related_morphs_id_column_index').on(table.relatedId), + }; + } +); + +export const filesFolderLinks = pgTable( + 'files_folder_links', + { + id: serial('id').primaryKey().notNull(), + fileId: integer('file_id').references(() => files.id, { onDelete: 'cascade' }), + folderId: integer('folder_id').references(() => uploadFolders.id, { onDelete: 'cascade' }), + fileOrder: doublePrecision('file_order'), + }, + (table) => { + return { + fk: index('files_folder_links_fk').on(table.fileId), + invFk: index('files_folder_links_inv_fk').on(table.folderId), + orderInvFk: index('files_folder_links_order_inv_fk').on(table.fileOrder), + filesFolderLinksUnique: unique('files_folder_links_unique').on(table.fileId, table.folderId), + }; + } +); + +export const uploadFoldersParentLinks = pgTable( + 'upload_folders_parent_links', + { + id: serial('id').primaryKey().notNull(), + folderId: integer('folder_id').references(() => uploadFolders.id, { onDelete: 'cascade' }), + invFolderId: integer('inv_folder_id').references(() => uploadFolders.id, { onDelete: 'cascade' }), + folderOrder: doublePrecision('folder_order'), + }, + (table) => { + return { + fk: index('upload_folders_parent_links_fk').on(table.folderId), + invFk: index('upload_folders_parent_links_inv_fk').on(table.invFolderId), + orderInvFk: index('upload_folders_parent_links_order_inv_fk').on(table.folderOrder), + uploadFoldersParentLinksUnique: unique('upload_folders_parent_links_unique').on( + table.folderId, + table.invFolderId + ), + }; + } +); + +export const strapiReleaseActionsReleaseLinks = pgTable( + 'strapi_release_actions_release_links', + { + id: serial('id').primaryKey().notNull(), + releaseActionId: integer('release_action_id').references(() => strapiReleaseActions.id, { onDelete: 'cascade' }), + releaseId: integer('release_id').references(() => strapiReleases.id, { onDelete: 'cascade' }), + releaseActionOrder: doublePrecision('release_action_order'), + }, + (table) => { + return { + fk: index('strapi_release_actions_release_links_fk').on(table.releaseActionId), + invFk: index('strapi_release_actions_release_links_inv_fk').on(table.releaseId), + orderInvFk: index('strapi_release_actions_release_links_order_inv_fk').on(table.releaseActionOrder), + strapiReleaseActionsReleaseLinksUnique: unique('strapi_release_actions_release_links_unique').on( + table.releaseActionId, + table.releaseId + ), + }; + } +); + +export const upPermissionsRoleLinks = pgTable( + 'up_permissions_role_links', + { + id: serial('id').primaryKey().notNull(), + permissionId: integer('permission_id').references(() => upPermissions.id, { onDelete: 'cascade' }), + roleId: integer('role_id').references(() => upRoles.id, { onDelete: 'cascade' }), + permissionOrder: doublePrecision('permission_order'), + }, + (table) => { + return { + fk: index('up_permissions_role_links_fk').on(table.permissionId), + invFk: index('up_permissions_role_links_inv_fk').on(table.roleId), + orderInvFk: index('up_permissions_role_links_order_inv_fk').on(table.permissionOrder), + upPermissionsRoleLinksUnique: unique('up_permissions_role_links_unique').on(table.permissionId, table.roleId), + }; + } +); + +export const upUsersRoleLinks = pgTable( + 'up_users_role_links', + { + id: serial('id').primaryKey().notNull(), + userId: integer('user_id').references(() => upUsers.id, { onDelete: 'cascade' }), + roleId: integer('role_id').references(() => upRoles.id, { onDelete: 'cascade' }), + userOrder: doublePrecision('user_order'), + }, + (table) => { + return { + fk: index('up_users_role_links_fk').on(table.userId), + invFk: index('up_users_role_links_inv_fk').on(table.roleId), + orderInvFk: index('up_users_role_links_order_inv_fk').on(table.userOrder), + upUsersRoleLinksUnique: unique('up_users_role_links_unique').on(table.userId, table.roleId), + }; + } +); + +export const methodsLocalizationsLinks = pgTable( + 'methods_localizations_links', + { + id: serial('id').primaryKey().notNull(), + methodId: integer('method_id').references(() => methods.id, { onDelete: 'cascade' }), + invMethodId: integer('inv_method_id').references(() => methods.id, { onDelete: 'cascade' }), + methodOrder: doublePrecision('method_order'), + }, + (table) => { + return { + fk: index('methods_localizations_links_fk').on(table.methodId), + invFk: index('methods_localizations_links_inv_fk').on(table.invMethodId), + orderFk: index('methods_localizations_links_order_fk').on(table.methodOrder), + methodsLocalizationsLinksUnique: unique('methods_localizations_links_unique').on( + table.methodId, + table.invMethodId + ), + }; + } +); + +export const terms = pgTable( + 'terms', + { + id: serial('id').primaryKey().notNull(), + slug: varchar('slug', { length: 255 }), + createdAt: timestamp('created_at', { precision: 6, mode: 'string' }), + updatedAt: timestamp('updated_at', { precision: 6, mode: 'string' }), + publishedAt: timestamp('published_at', { precision: 6, mode: 'string' }), + createdById: integer('created_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + updatedById: integer('updated_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + }, + (table) => { + return { + createdByIdFk: index('terms_created_by_id_fk').on(table.createdById), + updatedByIdFk: index('terms_updated_by_id_fk').on(table.updatedById), + }; + } +); + +export const events = pgTable( + 'events', + { + id: serial('id').primaryKey().notNull(), + title: varchar('title', { length: 255 }).notNull(), + intro: text('intro').notNull(), + start: timestamp('start', { precision: 6, mode: 'string' }).notNull(), + end: timestamp('end', { precision: 6, mode: 'string' }).notNull(), + subject: varchar('subject', { length: 255 }).notNull(), + address: varchar('address', { length: 255 }).notNull(), + content: text('content').notNull(), + slug: varchar('slug', { length: 255 }).notNull(), + addressName: varchar('address_name', { length: 255 }).notNull(), + eventbrite: text('eventbrite'), + eventbriteTitle: varchar('eventbrite_title', { length: 255 }), + createdAt: timestamp('created_at', { precision: 6, mode: 'string' }), + updatedAt: timestamp('updated_at', { precision: 6, mode: 'string' }), + publishedAt: timestamp('published_at', { precision: 6, mode: 'string' }), + createdById: integer('created_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + updatedById: integer('updated_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + report: text('report'), + }, + (table) => { + return { + createdByIdFk: index('events_created_by_id_fk').on(table.createdById), + updatedByIdFk: index('events_updated_by_id_fk').on(table.updatedById), + eventsSlugUnique: unique('events_slug_unique').on(table.slug), + }; + } +); + +export const blogArticles = pgTable( + 'blog_articles', + { + id: serial('id').primaryKey().notNull(), + title: varchar('title', { length: 255 }), + category: varchar('category', { length: 255 }), + content: text('content'), + description: text('description'), + createdAt: timestamp('created_at', { precision: 6, mode: 'string' }), + updatedAt: timestamp('updated_at', { precision: 6, mode: 'string' }), + publishedAt: timestamp('published_at', { precision: 6, mode: 'string' }), + createdById: integer('created_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + updatedById: integer('updated_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + source: text('source'), + }, + (table) => { + return { + createdByIdFk: index('blog_articles_created_by_id_fk').on(table.createdById), + updatedByIdFk: index('blog_articles_updated_by_id_fk').on(table.updatedById), + }; + } +); + +export const publications = pgTable( + 'publications', + { + id: serial('id').primaryKey().notNull(), + title: varchar('title', { length: 255 }), + summary: text('summary'), + content: text('content'), + tags: text('tags'), + slug: varchar('slug', { length: 255 }), + authors: text('authors'), + location: varchar('location', { length: 255 }), + createdAt: timestamp('created_at', { precision: 6, mode: 'string' }), + updatedAt: timestamp('updated_at', { precision: 6, mode: 'string' }), + publishedAt: timestamp('published_at', { precision: 6, mode: 'string' }), + createdById: integer('created_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + updatedById: integer('updated_by_id').references(() => adminUsers.id, { onDelete: 'set null' }), + cite: text('cite'), + originalSource: varchar('original_source', { length: 255 }), + publicationDate: date('publication_date'), + }, + (table) => { + return { + createdByIdFk: index('publications_created_by_id_fk').on(table.createdById), + updatedByIdFk: index('publications_updated_by_id_fk').on(table.updatedById), + publicationsSlugUnique: unique('publications_slug_unique').on(table.slug), + }; + } +);