diff --git a/scripts/check-db.ts b/scripts/check-db.ts new file mode 100644 index 0000000..1570044 --- /dev/null +++ b/scripts/check-db.ts @@ -0,0 +1,9 @@ +import { createRequire } from 'module' +const require = createRequire(import.meta.url) +const { Pool } = require('d:/Project/gbmake/gb-payload/node_modules/.pnpm/pg@8.16.3/node_modules/pg') +const pool = new Pool({ connectionString: 'postgres://gb-payload:123123@localhost/gb-payload' }) +const t = await pool.query(`SELECT tablename FROM pg_tables WHERE schemaname='public' AND tablename LIKE 'disassem%' ORDER BY tablename`) +console.log('Disassembly tables:', t.rows.map((r: any) => r.tablename)) +const m = await pool.query('SELECT name FROM payload_migrations ORDER BY id') +console.log('Migrations:', m.rows.map((r: any) => r.name)) +await pool.end() diff --git a/scripts/fix-migrations.ts b/scripts/fix-migrations.ts new file mode 100644 index 0000000..381832b --- /dev/null +++ b/scripts/fix-migrations.ts @@ -0,0 +1,211 @@ +/** + * Fix script: Re-insert historical migration records and apply new migration + * using a direct pg connection (no Payload init to avoid dev-mode push loops). + * + * Run with: pnpm tsx --env-file=.env scripts/fix-migrations.ts + */ +import { createRequire } from 'module' +const require = createRequire(import.meta.url) + +const { Pool } = require( + 'd:/Project/gbmake/gb-payload/node_modules/.pnpm/pg@8.16.3/node_modules/pg' +) + +const pool = new Pool({ + connectionString: process.env.DATABASE_URL ?? 'postgres://gb-payload:123123@localhost/gb-payload', +}) + +async function run(sql: string, params: any[] = []) { + const result = await pool.query(sql, params) + return result.rows +} + +// ── Check current migration state ──────────────────────────────────────────── +console.log('📋 Checking payload_migrations table...') +const existing = await run(`SELECT name FROM payload_migrations ORDER BY id`) +const existingNames = new Set(existing.map((r: any) => r.name)) +console.log('Currently recorded:', existingNames.size > 0 ? [...existingNames] : '(none)') + +// ── Mark all historical migrations as done ──────────────────────────────────── +const historyMigrations = [ + '20260208_171142', + '20260212_193303', + '20260212_202303', + '20260222_170233', + 'hero_slider_simplify', + 'product_recommendations_simplify', +] + +for (const name of historyMigrations) { + if (!existingNames.has(name)) { + await run( + `INSERT INTO payload_migrations (name, batch, updated_at, created_at) VALUES ($1, 1, now(), now())`, + [name] + ) + console.log(`✅ Marked done: ${name}`) + } else { + console.log(`⏭️ Already recorded: ${name}`) + } +} + +// ── Skip if new migration already applied ───────────────────────────────────── +if (existingNames.has('20260223_disassembly_refactor')) { + console.log('\n⏭️ Migration 20260223_disassembly_refactor already applied.') + await pool.end() + process.exit(0) +} + +// ── Show what disassembly tables exist ─────────────────────────────────────── +const disasmTables = await run( + `SELECT tablename FROM pg_tables WHERE schemaname='public' AND tablename LIKE 'disassembly%' ORDER BY tablename` +) +console.log('\nCurrent disassembly tables:', disasmTables.map((r: any) => r.tablename)) + +console.log('\n🔧 Applying: 20260223_disassembly_refactor ...') + +try { + // 1. disassembly_components + await run(`CREATE TABLE IF NOT EXISTS disassembly_components ( + id serial PRIMARY KEY NOT NULL, + label varchar NOT NULL, + start_coordinate_x numeric DEFAULT 0 NOT NULL, + start_coordinate_y numeric DEFAULT 0 NOT NULL, + start_radius numeric DEFAULT 20 NOT NULL, + updated_at timestamp(3) with time zone DEFAULT now() NOT NULL, + created_at timestamp(3) with time zone DEFAULT now() NOT NULL + )`) + await run(`CREATE INDEX IF NOT EXISTS disassembly_components_updated_at_idx ON disassembly_components USING btree (updated_at)`) + await run(`CREATE INDEX IF NOT EXISTS disassembly_components_created_at_idx ON disassembly_components USING btree (created_at)`) + console.log(' ✅ disassembly_components') + + // 2. disassembly_linked_products + await run(`CREATE TABLE IF NOT EXISTS disassembly_linked_products ( + id serial PRIMARY KEY NOT NULL, + coordinate_x numeric DEFAULT 0 NOT NULL, + coordinate_y numeric DEFAULT 0 NOT NULL, + product_name varchar, + updated_at timestamp(3) with time zone DEFAULT now() NOT NULL, + created_at timestamp(3) with time zone DEFAULT now() NOT NULL + )`) + await run(`CREATE INDEX IF NOT EXISTS disassembly_linked_products_updated_at_idx ON disassembly_linked_products USING btree (updated_at)`) + await run(`CREATE INDEX IF NOT EXISTS disassembly_linked_products_created_at_idx ON disassembly_linked_products USING btree (created_at)`) + console.log(' ✅ disassembly_linked_products') + + // 3. disassembly_components_rels + await run(`CREATE TABLE IF NOT EXISTS disassembly_components_rels ( + id serial PRIMARY KEY NOT NULL, + "order" integer, + parent_id integer NOT NULL, + path varchar NOT NULL, + disassembly_linked_products_id integer + )`) + await run(`DO $$ BEGIN + IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'disassembly_components_rels_parent_fk') THEN + ALTER TABLE disassembly_components_rels ADD CONSTRAINT disassembly_components_rels_parent_fk + FOREIGN KEY (parent_id) REFERENCES disassembly_components(id) ON DELETE cascade; + END IF; + END $$`) + await run(`DO $$ BEGIN + IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'disassembly_components_rels_disassembly_linked_products_fk') THEN + ALTER TABLE disassembly_components_rels ADD CONSTRAINT disassembly_components_rels_disassembly_linked_products_fk + FOREIGN KEY (disassembly_linked_products_id) REFERENCES disassembly_linked_products(id) ON DELETE cascade; + END IF; + END $$`) + await run(`CREATE INDEX IF NOT EXISTS disassembly_components_rels_order_idx ON disassembly_components_rels USING btree ("order")`) + await run(`CREATE INDEX IF NOT EXISTS disassembly_components_rels_parent_idx ON disassembly_components_rels USING btree (parent_id)`) + await run(`CREATE INDEX IF NOT EXISTS disassembly_components_rels_path_idx ON disassembly_components_rels USING btree (path)`) + await run(`CREATE INDEX IF NOT EXISTS disassembly_components_rels_disassembly_linked_products_id_idx ON disassembly_components_rels USING btree (disassembly_linked_products_id)`) + console.log(' ✅ disassembly_components_rels') + + // 4. disassembly_linked_products_rels + await run(`CREATE TABLE IF NOT EXISTS disassembly_linked_products_rels ( + id serial PRIMARY KEY NOT NULL, + "order" integer, + parent_id integer NOT NULL, + path varchar NOT NULL, + products_id integer, + preorder_products_id integer + )`) + await run(`DO $$ BEGIN + IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'disassembly_linked_products_rels_parent_fk') THEN + ALTER TABLE disassembly_linked_products_rels ADD CONSTRAINT disassembly_linked_products_rels_parent_fk + FOREIGN KEY (parent_id) REFERENCES disassembly_linked_products(id) ON DELETE cascade; + END IF; + END $$`) + await run(`DO $$ BEGIN + IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'disassembly_linked_products_rels_products_fk') THEN + ALTER TABLE disassembly_linked_products_rels ADD CONSTRAINT disassembly_linked_products_rels_products_fk + FOREIGN KEY (products_id) REFERENCES products(id) ON DELETE cascade; + END IF; + END $$`) + await run(`DO $$ BEGIN + IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'disassembly_linked_products_rels_preorder_products_fk') THEN + ALTER TABLE disassembly_linked_products_rels ADD CONSTRAINT disassembly_linked_products_rels_preorder_products_fk + FOREIGN KEY (preorder_products_id) REFERENCES preorder_products(id) ON DELETE cascade; + END IF; + END $$`) + await run(`CREATE INDEX IF NOT EXISTS disassembly_linked_products_rels_order_idx ON disassembly_linked_products_rels USING btree ("order")`) + await run(`CREATE INDEX IF NOT EXISTS disassembly_linked_products_rels_parent_idx ON disassembly_linked_products_rels USING btree (parent_id)`) + await run(`CREATE INDEX IF NOT EXISTS disassembly_linked_products_rels_path_idx ON disassembly_linked_products_rels USING btree (path)`) + await run(`CREATE INDEX IF NOT EXISTS disassembly_linked_products_rels_products_id_idx ON disassembly_linked_products_rels USING btree (products_id)`) + await run(`CREATE INDEX IF NOT EXISTS disassembly_linked_products_rels_preorder_products_id_idx ON disassembly_linked_products_rels USING btree (preorder_products_id)`) + console.log(' ✅ disassembly_linked_products_rels') + + // 5. Update disassembly_pages_rels + await run(`ALTER TABLE disassembly_pages_rels DROP CONSTRAINT IF EXISTS disassembly_pages_rels_products_fk`) + await run(`ALTER TABLE disassembly_pages_rels DROP CONSTRAINT IF EXISTS disassembly_pages_rels_preorder_products_fk`) + await run(`DROP INDEX IF EXISTS disassembly_pages_rels_products_id_idx`) + await run(`DROP INDEX IF EXISTS disassembly_pages_rels_preorder_products_id_idx`) + const pc = await run(`SELECT 1 FROM information_schema.columns WHERE table_name='disassembly_pages_rels' AND column_name='products_id'`) + if (pc.length > 0) await run(`ALTER TABLE disassembly_pages_rels DROP COLUMN products_id`) + const prc = await run(`SELECT 1 FROM information_schema.columns WHERE table_name='disassembly_pages_rels' AND column_name='preorder_products_id'`) + if (prc.length > 0) await run(`ALTER TABLE disassembly_pages_rels DROP COLUMN preorder_products_id`) + await run(`ALTER TABLE disassembly_pages_rels ADD COLUMN IF NOT EXISTS disassembly_components_id integer`) + await run(`DO $$ BEGIN + IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'disassembly_pages_rels_disassembly_components_fk') THEN + ALTER TABLE disassembly_pages_rels ADD CONSTRAINT disassembly_pages_rels_disassembly_components_fk + FOREIGN KEY (disassembly_components_id) REFERENCES disassembly_components(id) ON DELETE cascade; + END IF; + END $$`) + await run(`CREATE INDEX IF NOT EXISTS disassembly_pages_rels_disassembly_components_id_idx ON disassembly_pages_rels USING btree (disassembly_components_id)`) + console.log(' ✅ disassembly_pages_rels updated') + + // 6. Update payload_locked_documents_rels + await run(`ALTER TABLE payload_locked_documents_rels ADD COLUMN IF NOT EXISTS disassembly_components_id integer`) + await run(`ALTER TABLE payload_locked_documents_rels ADD COLUMN IF NOT EXISTS disassembly_linked_products_id integer`) + await run(`DO $$ BEGIN + IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'payload_locked_documents_rels_disassembly_components_fk') THEN + ALTER TABLE payload_locked_documents_rels ADD CONSTRAINT payload_locked_documents_rels_disassembly_components_fk + FOREIGN KEY (disassembly_components_id) REFERENCES disassembly_components(id) ON DELETE cascade; + END IF; + END $$`) + await run(`DO $$ BEGIN + IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'payload_locked_documents_rels_disassembly_linked_products_fk') THEN + ALTER TABLE payload_locked_documents_rels ADD CONSTRAINT payload_locked_documents_rels_disassembly_linked_products_fk + FOREIGN KEY (disassembly_linked_products_id) REFERENCES disassembly_linked_products(id) ON DELETE cascade; + END IF; + END $$`) + await run(`CREATE INDEX IF NOT EXISTS payload_locked_documents_rels_disassembly_components_id_idx ON payload_locked_documents_rels USING btree (disassembly_components_id)`) + await run(`CREATE INDEX IF NOT EXISTS payload_locked_documents_rels_disassembly_linked_products_id_idx ON payload_locked_documents_rels USING btree (disassembly_linked_products_id)`) + console.log(' ✅ payload_locked_documents_rels updated') + + // 7. Drop old array tables + await run(`DROP TABLE IF EXISTS disassembly_pages_components_linked_products CASCADE`) + await run(`DROP TABLE IF EXISTS disassembly_pages_components CASCADE`) + console.log(' ✅ Old array tables dropped') + + // 8. Record migration + await run( + `INSERT INTO payload_migrations (name, batch, updated_at, created_at) VALUES ($1, 2, now(), now())`, + ['20260223_disassembly_refactor'] + ) + console.log('\n🎉 Migration 20260223_disassembly_refactor applied successfully!') + +} catch (err: any) { + console.error('\n❌ Error:', err?.message ?? err) + await pool.end() + process.exit(1) +} + +await pool.end() +process.exit(0) diff --git a/src/app/api/home/route.ts b/src/app/api/home/route.ts index 7cd7772..676c822 100644 --- a/src/app/api/home/route.ts +++ b/src/app/api/home/route.ts @@ -95,9 +95,9 @@ export async function GET(req: NextRequest) { orderCount: totalCount, startDate: product.preorderStartDate, endDate: product.preorderEndDate, - // 计算进度百分比(含 fakeOrderCount,用于展示) + // 计算进度百分比(含 fakeOrderCount,用于展示,不限制 100 以支持超出显示) progress: product.fundingGoal > 0 - ? Math.min(Math.round((totalCount / product.fundingGoal) * 100), 100) + ? Math.round((totalCount / product.fundingGoal) * 100) : 0, // 计算剩余天数 daysLeft: product.preorderEndDate diff --git a/src/app/api/preorders/[id]/orders/route.ts b/src/app/api/preorders/[id]/orders/route.ts index 0a2d591..80d96c5 100644 --- a/src/app/api/preorders/[id]/orders/route.ts +++ b/src/app/api/preorders/[id]/orders/route.ts @@ -2,6 +2,8 @@ import { NextRequest, NextResponse } from 'next/server' import { getPayload } from 'payload' import config from '@payload-config' +const MEDUSA_PUBLISHABLE_KEY = process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY || '' + /** * 获取预购产品的订单列表(从 Medusa 获取) * GET /api/preorders/:id/orders @@ -57,9 +59,10 @@ export async function GET( // 从 Medusa 获取订单数据 const medusaUrl = process.env.MEDUSA_BACKEND_URL || 'http://localhost:9000' - const medusaResponse = await fetch(`${medusaUrl}/admin/orders`, { + const medusaResponse = await fetch(`${medusaUrl}/admin/orders?limit=500`, { headers: { 'Content-Type': 'application/json', + 'x-publishable-api-key': MEDUSA_PUBLISHABLE_KEY, }, }) diff --git a/src/app/api/preorders/refresh-order-counts/route.ts b/src/app/api/preorders/refresh-order-counts/route.ts index 9cd1c8f..7b3ef97 100644 --- a/src/app/api/preorders/refresh-order-counts/route.ts +++ b/src/app/api/preorders/refresh-order-counts/route.ts @@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from 'next/server' import payload from 'payload' const MEDUSA_BACKEND_URL = process.env.MEDUSA_BACKEND_URL || 'http://localhost:9000' -const MEDUSA_ADMIN_API_KEY = process.env.MEDUSA_ADMIN_API_KEY || '' +const MEDUSA_PUBLISHABLE_KEY = process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY || '' /** * 刷新预购商品的订单计数 @@ -77,7 +77,7 @@ export async function POST(req: NextRequest) { `${MEDUSA_BACKEND_URL}/admin/orders?product_id=${medusaId}&limit=1000`, { headers: { - 'x-medusa-access-token': MEDUSA_ADMIN_API_KEY, + 'x-publishable-api-key': MEDUSA_PUBLISHABLE_KEY, 'Content-Type': 'application/json', }, } diff --git a/src/collections/disassembly/DisassemblyComponents.ts b/src/collections/disassembly/DisassemblyComponents.ts new file mode 100644 index 0000000..03e405e --- /dev/null +++ b/src/collections/disassembly/DisassemblyComponents.ts @@ -0,0 +1,93 @@ +import type { CollectionConfig } from 'payload' +import { logAfterChange, logAfterDelete } from '../../hooks/logAction' +import { cacheAfterChange, cacheAfterDelete } from '../../hooks/cacheInvalidation' + +/** + * 第二层 - 拆解组件 + * + * 属于某个拆解页(DisassemblyPages),记录锚点坐标、热区半径及关联商品信息列表。 + * 不在管理后台导航中显示,通过拆解页的 components 关联管理。 + */ +export const DisassemblyComponents: CollectionConfig = { + slug: 'disassembly-components', + admin: { + useAsTitle: 'label', + hidden: true, + description: '拆解页中的拆解组件(通过拆解页管理)', + defaultColumns: ['label', 'startRadius', 'updatedAt'], + }, + access: { + read: () => true, + create: ({ req: { user } }) => !!user, + update: ({ req: { user } }) => !!user, + delete: ({ req: { user } }) => !!user, + }, + hooks: { + afterChange: [logAfterChange, cacheAfterChange], + afterDelete: [logAfterDelete, cacheAfterDelete], + }, + fields: [ + // 组件名称(Admin 面板标识用) + { + name: 'label', + label: '组件名称', + type: 'text', + required: true, + admin: { + description: '用于 Admin 面板中标识该组件', + }, + }, + + // 起点坐标 + { + name: 'startCoordinate', + label: '起点坐标', + type: 'group', + admin: { + description: '组件锚点在页面/图片上的坐标', + }, + fields: [ + { + name: 'x', + label: 'X', + type: 'number', + required: true, + defaultValue: 0, + admin: { description: '水平坐标' }, + }, + { + name: 'y', + label: 'Y', + type: 'number', + required: true, + defaultValue: 0, + admin: { description: '垂直坐标' }, + }, + ], + }, + + // 起点坐标半径 + { + name: 'startRadius', + label: '起点坐标半径', + type: 'number', + required: true, + defaultValue: 20, + admin: { + description: '锚点热区半径(px)', + }, + }, + + // 第三层:关联商品信息列表 + { + name: 'linkedProducts', + label: '关联商品信息', + type: 'relationship', + relationTo: 'disassembly-linked-products', + hasMany: true, + admin: { + description: '该组件下的关联商品信息条目', + }, + }, + ], +} diff --git a/src/collections/disassembly/DisassemblyLinkedProducts.ts b/src/collections/disassembly/DisassemblyLinkedProducts.ts new file mode 100644 index 0000000..752e4f6 --- /dev/null +++ b/src/collections/disassembly/DisassemblyLinkedProducts.ts @@ -0,0 +1,92 @@ +import type { CollectionConfig } from 'payload' +import { logAfterChange, logAfterDelete } from '../../hooks/logAction' +import { cacheAfterChange, cacheAfterDelete } from '../../hooks/cacheInvalidation' + +/** + * 第三层 - 关联商品信息 + * + * 属于某个拆解组件(DisassemblyComponents),记录标注坐标及关联的商品/预售商品。 + * 不在管理后台导航中显示,通过拆解组件的 linkedProducts 关联管理。 + */ +export const DisassemblyLinkedProducts: CollectionConfig = { + slug: 'disassembly-linked-products', + admin: { + useAsTitle: 'productName', + hidden: true, + description: '拆解组件中的关联商品信息(通过拆解组件管理)', + defaultColumns: ['productName', 'products', 'preorderProducts', 'updatedAt'], + }, + access: { + read: () => true, + create: ({ req: { user } }) => !!user, + update: ({ req: { user } }) => !!user, + delete: ({ req: { user } }) => !!user, + }, + hooks: { + afterChange: [logAfterChange, cacheAfterChange], + afterDelete: [logAfterDelete, cacheAfterDelete], + }, + fields: [ + // 具体坐标(商品标注在图片上的坐标) + { + name: 'coordinate', + label: '具体坐标', + type: 'group', + admin: { + description: '商品标注在图片上的坐标', + }, + fields: [ + { + name: 'x', + label: 'X', + type: 'number', + required: true, + defaultValue: 0, + admin: { description: '水平坐标' }, + }, + { + name: 'y', + label: 'Y', + type: 'number', + required: true, + defaultValue: 0, + admin: { description: '垂直坐标' }, + }, + ], + }, + + // 商品名称(显示用,留空则使用关联商品标题) + { + name: 'productName', + label: '商品名称', + type: 'text', + admin: { + description: '展示在标注上的商品名称,留空则使用关联商品标题', + }, + }, + + // 关联普通商品列表 + { + name: 'products', + label: '关联商品 (Products)', + type: 'relationship', + relationTo: 'products', + hasMany: true, + admin: { + description: '关联的普通商品', + }, + }, + + // 关联预售商品列表 + { + name: 'preorderProducts', + label: '关联预售商品 (PreorderProducts)', + type: 'relationship', + relationTo: 'preorder-products', + hasMany: true, + admin: { + description: '关联的预售商品', + }, + }, + ], +} diff --git a/src/collections/disassembly/DisassemblyPages.ts b/src/collections/disassembly/DisassemblyPages.ts new file mode 100644 index 0000000..1654055 --- /dev/null +++ b/src/collections/disassembly/DisassemblyPages.ts @@ -0,0 +1,73 @@ +import type { CollectionConfig } from 'payload' +import { logAfterChange, logAfterDelete } from '../../hooks/logAction' +import { cacheAfterChange, cacheAfterDelete } from '../../hooks/cacheInvalidation' + +/** + * 第一层 - 拆解页 + * + * 顶层 Collection,在管理后台导航中可见。 + * 包含主图、名称、URL 及拆解组件列表(关联 DisassemblyComponents)。 + * + * 数据层级: + * DisassemblyPages + * └─ components[] → DisassemblyComponents (第二层) + * └─ linkedProducts[] → DisassemblyLinkedProducts (第三层) + */ +export const DisassemblyPages: CollectionConfig = { + slug: 'disassembly-pages', + admin: { + useAsTitle: 'name', + defaultColumns: ['mainImage', 'name', 'url', 'updatedAt'], + description: '管理产品拆解页,包含拆解组件和关联商品信息', + pagination: { + defaultLimit: 25, + }, + }, + access: { + read: () => true, + create: ({ req: { user } }) => !!user, + update: ({ req: { user } }) => !!user, + delete: ({ req: { user } }) => !!user, + }, + hooks: { + afterChange: [logAfterChange, cacheAfterChange], + afterDelete: [logAfterDelete, cacheAfterDelete], + }, + fields: [ + // 主图 + { + name: 'mainImage', + label: '主图', + type: 'upload', + relationTo: 'media', + required: true, + }, + // 名称 + { + name: 'name', + label: '名称', + type: 'text', + required: true, + }, + // URL 链接 + { + name: 'url', + label: 'URL 链接', + type: 'text', + admin: { + description: '该拆解页对应的页面路径或外部链接', + }, + }, + // 第二层:拆解组件列表 + { + name: 'components', + label: '拆解组件', + type: 'relationship', + relationTo: 'disassembly-components', + hasMany: true, + admin: { + description: '该拆解页包含的拆解组件列表', + }, + }, + ], +} diff --git a/src/components/cells/PreorderProgressCell.tsx b/src/components/cells/PreorderProgressCell.tsx index 4ae3248..4547e36 100644 --- a/src/components/cells/PreorderProgressCell.tsx +++ b/src/components/cells/PreorderProgressCell.tsx @@ -11,7 +11,9 @@ export function PreorderProgressCell({ rowData }: any) { const fundingGoal = parseInt(rowData?.fundingGoal || '0', 10) || 100 const totalCount = orderCount + fakeOrderCount - const percentage = fundingGoal > 0 ? Math.min(Math.round((totalCount / fundingGoal) * 100), 100) : 0 + const percentage = fundingGoal > 0 ? Math.round((totalCount / fundingGoal) * 100) : 0 + const isExceeded = percentage > 100 + const barWidth = Math.min(percentage, 100) return (
@@ -22,11 +24,27 @@ export function PreorderProgressCell({ rowData }: any) {
-
+
+ {isExceeded && ( +
+ )}
@@ -40,7 +58,9 @@ export function PreorderProgressCell({ rowData }: any) {
完成度 - {percentage}% + + {isExceeded ? `超出 ${percentage - 100}%` : `${percentage}%`} +
diff --git a/src/migrations/20260222_170233.json b/src/migrations/20260222_170233.json new file mode 100644 index 0000000..1ca01c1 --- /dev/null +++ b/src/migrations/20260222_170233.json @@ -0,0 +1,5445 @@ +{ + "version": "7", + "dialect": "postgresql", + "tables": { + "public.users_roles": { + "name": "users_roles", + "schema": "", + "columns": { + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "parent_id": { + "name": "parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "enum_users_roles", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + } + }, + "indexes": { + "users_roles_order_idx": { + "name": "users_roles_order_idx", + "columns": [ + { + "expression": "order", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "users_roles_parent_idx": { + "name": "users_roles_parent_idx", + "columns": [ + { + "expression": "parent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "users_roles_parent_fk": { + "name": "users_roles_parent_fk", + "tableFrom": "users_roles", + "tableTo": "users", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.users_sessions": { + "name": "users_sessions", + "schema": "", + "columns": { + "_order": { + "name": "_order", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "_parent_id": { + "name": "_parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "varchar", + "primaryKey": true, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "users_sessions_order_idx": { + "name": "users_sessions_order_idx", + "columns": [ + { + "expression": "_order", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "users_sessions_parent_id_idx": { + "name": "users_sessions_parent_id_idx", + "columns": [ + { + "expression": "_parent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "users_sessions_parent_id_fk": { + "name": "users_sessions_parent_id_fk", + "tableFrom": "users_sessions", + "tableTo": "users", + "columnsFrom": [ + "_parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "email": { + "name": "email", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "reset_password_token": { + "name": "reset_password_token", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "reset_password_expiration": { + "name": "reset_password_expiration", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "salt": { + "name": "salt", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "hash": { + "name": "hash", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "login_attempts": { + "name": "login_attempts", + "type": "numeric", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "lock_until": { + "name": "lock_until", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "users_updated_at_idx": { + "name": "users_updated_at_idx", + "columns": [ + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "users_created_at_idx": { + "name": "users_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "users_email_idx": { + "name": "users_email_idx", + "columns": [ + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.media": { + "name": "media", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "alt": { + "name": "alt", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "url": { + "name": "url", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "thumbnail_u_r_l": { + "name": "thumbnail_u_r_l", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "filename": { + "name": "filename", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "mime_type": { + "name": "mime_type", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "filesize": { + "name": "filesize", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "width": { + "name": "width", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "height": { + "name": "height", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "focal_x": { + "name": "focal_x", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "focal_y": { + "name": "focal_y", + "type": "numeric", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "media_updated_at_idx": { + "name": "media_updated_at_idx", + "columns": [ + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "media_created_at_idx": { + "name": "media_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "media_filename_idx": { + "name": "media_filename_idx", + "columns": [ + { + "expression": "filename", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.products_taobao_links": { + "name": "products_taobao_links", + "schema": "", + "columns": { + "_order": { + "name": "_order", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "_parent_id": { + "name": "_parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "varchar", + "primaryKey": true, + "notNull": true + }, + "url": { + "name": "url", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "thumbnail": { + "name": "thumbnail", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "varchar", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "products_taobao_links_order_idx": { + "name": "products_taobao_links_order_idx", + "columns": [ + { + "expression": "_order", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "products_taobao_links_parent_id_idx": { + "name": "products_taobao_links_parent_id_idx", + "columns": [ + { + "expression": "_parent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "products_taobao_links_parent_id_fk": { + "name": "products_taobao_links_parent_id_fk", + "tableFrom": "products_taobao_links", + "tableTo": "products", + "columnsFrom": [ + "_parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.products": { + "name": "products", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "medusa_id": { + "name": "medusa_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "handle": { + "name": "handle", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "enum_products_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "seed_id": { + "name": "seed_id", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "thumbnail": { + "name": "thumbnail", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "start_price": { + "name": "start_price", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "last_synced_at": { + "name": "last_synced_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "content": { + "name": "content", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "tags": { + "name": "tags", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "collection": { + "name": "collection", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "height": { + "name": "height", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "width": { + "name": "width", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "length": { + "name": "length", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "weight": { + "name": "weight", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "mid_code": { + "name": "mid_code", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "hs_code": { + "name": "hs_code", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "country_of_origin": { + "name": "country_of_origin", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "products_medusa_id_idx": { + "name": "products_medusa_id_idx", + "columns": [ + { + "expression": "medusa_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "products_handle_idx": { + "name": "products_handle_idx", + "columns": [ + { + "expression": "handle", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "products_seed_id_idx": { + "name": "products_seed_id_idx", + "columns": [ + { + "expression": "seed_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "products_updated_at_idx": { + "name": "products_updated_at_idx", + "columns": [ + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "products_created_at_idx": { + "name": "products_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.products_rels": { + "name": "products_rels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parent_id": { + "name": "parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "products_id": { + "name": "products_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "preorder_products_id": { + "name": "preorder_products_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "products_rels_order_idx": { + "name": "products_rels_order_idx", + "columns": [ + { + "expression": "order", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "products_rels_parent_idx": { + "name": "products_rels_parent_idx", + "columns": [ + { + "expression": "parent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "products_rels_path_idx": { + "name": "products_rels_path_idx", + "columns": [ + { + "expression": "path", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "products_rels_products_id_idx": { + "name": "products_rels_products_id_idx", + "columns": [ + { + "expression": "products_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "products_rels_preorder_products_id_idx": { + "name": "products_rels_preorder_products_id_idx", + "columns": [ + { + "expression": "preorder_products_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "products_rels_parent_fk": { + "name": "products_rels_parent_fk", + "tableFrom": "products_rels", + "tableTo": "products", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "products_rels_products_fk": { + "name": "products_rels_products_fk", + "tableFrom": "products_rels", + "tableTo": "products", + "columnsFrom": [ + "products_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "products_rels_preorder_products_fk": { + "name": "products_rels_preorder_products_fk", + "tableFrom": "products_rels", + "tableTo": "preorder_products", + "columnsFrom": [ + "preorder_products_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.preorder_products_taobao_links": { + "name": "preorder_products_taobao_links", + "schema": "", + "columns": { + "_order": { + "name": "_order", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "_parent_id": { + "name": "_parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "varchar", + "primaryKey": true, + "notNull": true + }, + "url": { + "name": "url", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "thumbnail": { + "name": "thumbnail", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "varchar", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "preorder_products_taobao_links_order_idx": { + "name": "preorder_products_taobao_links_order_idx", + "columns": [ + { + "expression": "_order", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "preorder_products_taobao_links_parent_id_idx": { + "name": "preorder_products_taobao_links_parent_id_idx", + "columns": [ + { + "expression": "_parent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "preorder_products_taobao_links_parent_id_fk": { + "name": "preorder_products_taobao_links_parent_id_fk", + "tableFrom": "preorder_products_taobao_links", + "tableTo": "preorder_products", + "columnsFrom": [ + "_parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.preorder_products": { + "name": "preorder_products", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "medusa_id": { + "name": "medusa_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "handle": { + "name": "handle", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "enum_preorder_products_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "seed_id": { + "name": "seed_id", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "thumbnail": { + "name": "thumbnail", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "start_price": { + "name": "start_price", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "last_synced_at": { + "name": "last_synced_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "preorder_type": { + "name": "preorder_type", + "type": "enum_preorder_products_preorder_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'standard'" + }, + "funding_goal": { + "name": "funding_goal", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "preorder_start_date": { + "name": "preorder_start_date", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "preorder_end_date": { + "name": "preorder_end_date", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "order_count": { + "name": "order_count", + "type": "numeric", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "fake_order_count": { + "name": "fake_order_count", + "type": "numeric", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "content": { + "name": "content", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "tags": { + "name": "tags", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "collection": { + "name": "collection", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "height": { + "name": "height", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "width": { + "name": "width", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "length": { + "name": "length", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "weight": { + "name": "weight", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "mid_code": { + "name": "mid_code", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "hs_code": { + "name": "hs_code", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "country_of_origin": { + "name": "country_of_origin", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "preorder_products_medusa_id_idx": { + "name": "preorder_products_medusa_id_idx", + "columns": [ + { + "expression": "medusa_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "preorder_products_handle_idx": { + "name": "preorder_products_handle_idx", + "columns": [ + { + "expression": "handle", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "preorder_products_seed_id_idx": { + "name": "preorder_products_seed_id_idx", + "columns": [ + { + "expression": "seed_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "preorder_products_updated_at_idx": { + "name": "preorder_products_updated_at_idx", + "columns": [ + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "preorder_products_created_at_idx": { + "name": "preorder_products_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.preorder_products_rels": { + "name": "preorder_products_rels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parent_id": { + "name": "parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "products_id": { + "name": "products_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "preorder_products_id": { + "name": "preorder_products_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "preorder_products_rels_order_idx": { + "name": "preorder_products_rels_order_idx", + "columns": [ + { + "expression": "order", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "preorder_products_rels_parent_idx": { + "name": "preorder_products_rels_parent_idx", + "columns": [ + { + "expression": "parent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "preorder_products_rels_path_idx": { + "name": "preorder_products_rels_path_idx", + "columns": [ + { + "expression": "path", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "preorder_products_rels_products_id_idx": { + "name": "preorder_products_rels_products_id_idx", + "columns": [ + { + "expression": "products_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "preorder_products_rels_preorder_products_id_idx": { + "name": "preorder_products_rels_preorder_products_id_idx", + "columns": [ + { + "expression": "preorder_products_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "preorder_products_rels_parent_fk": { + "name": "preorder_products_rels_parent_fk", + "tableFrom": "preorder_products_rels", + "tableTo": "preorder_products", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "preorder_products_rels_products_fk": { + "name": "preorder_products_rels_products_fk", + "tableFrom": "preorder_products_rels", + "tableTo": "products", + "columnsFrom": [ + "products_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "preorder_products_rels_preorder_products_fk": { + "name": "preorder_products_rels_preorder_products_fk", + "tableFrom": "preorder_products_rels", + "tableTo": "preorder_products", + "columnsFrom": [ + "preorder_products_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.announcements": { + "name": "announcements", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "enum_announcements_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'info'" + }, + "status": { + "name": "status", + "type": "enum_announcements_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "priority": { + "name": "priority", + "type": "numeric", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "summary": { + "name": "summary", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "content": { + "name": "content", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "published_at": { + "name": "published_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "show_on_homepage": { + "name": "show_on_homepage", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "author_id": { + "name": "author_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "announcements_author_idx": { + "name": "announcements_author_idx", + "columns": [ + { + "expression": "author_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "announcements_updated_at_idx": { + "name": "announcements_updated_at_idx", + "columns": [ + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "announcements_created_at_idx": { + "name": "announcements_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "announcements_author_id_users_id_fk": { + "name": "announcements_author_id_users_id_fk", + "tableFrom": "announcements", + "tableTo": "users", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.articles": { + "name": "articles", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "enum_articles_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": false, + "default": "'draft'" + }, + "slug": { + "name": "slug", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "featured_image_id": { + "name": "featured_image_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "excerpt": { + "name": "excerpt", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "content": { + "name": "content", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "enum_articles_category", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "featured": { + "name": "featured", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "author_id": { + "name": "author_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "published_at": { + "name": "published_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "meta_title": { + "name": "meta_title", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "meta_description": { + "name": "meta_description", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "_status": { + "name": "_status", + "type": "enum_articles_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": false, + "default": "'draft'" + } + }, + "indexes": { + "articles_slug_idx": { + "name": "articles_slug_idx", + "columns": [ + { + "expression": "slug", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "articles_featured_image_idx": { + "name": "articles_featured_image_idx", + "columns": [ + { + "expression": "featured_image_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "articles_author_idx": { + "name": "articles_author_idx", + "columns": [ + { + "expression": "author_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "articles_updated_at_idx": { + "name": "articles_updated_at_idx", + "columns": [ + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "articles_created_at_idx": { + "name": "articles_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "articles__status_idx": { + "name": "articles__status_idx", + "columns": [ + { + "expression": "_status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "articles_featured_image_id_media_id_fk": { + "name": "articles_featured_image_id_media_id_fk", + "tableFrom": "articles", + "tableTo": "media", + "columnsFrom": [ + "featured_image_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "articles_author_id_users_id_fk": { + "name": "articles_author_id_users_id_fk", + "tableFrom": "articles", + "tableTo": "users", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.articles_texts": { + "name": "articles_texts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "parent_id": { + "name": "parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "text": { + "name": "text", + "type": "varchar", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "articles_texts_order_parent": { + "name": "articles_texts_order_parent", + "columns": [ + { + "expression": "order", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "parent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "articles_texts_parent_fk": { + "name": "articles_texts_parent_fk", + "tableFrom": "articles_texts", + "tableTo": "articles", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.articles_rels": { + "name": "articles_rels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parent_id": { + "name": "parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "articles_id": { + "name": "articles_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "products_id": { + "name": "products_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "articles_rels_order_idx": { + "name": "articles_rels_order_idx", + "columns": [ + { + "expression": "order", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "articles_rels_parent_idx": { + "name": "articles_rels_parent_idx", + "columns": [ + { + "expression": "parent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "articles_rels_path_idx": { + "name": "articles_rels_path_idx", + "columns": [ + { + "expression": "path", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "articles_rels_articles_id_idx": { + "name": "articles_rels_articles_id_idx", + "columns": [ + { + "expression": "articles_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "articles_rels_products_id_idx": { + "name": "articles_rels_products_id_idx", + "columns": [ + { + "expression": "products_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "articles_rels_parent_fk": { + "name": "articles_rels_parent_fk", + "tableFrom": "articles_rels", + "tableTo": "articles", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "articles_rels_articles_fk": { + "name": "articles_rels_articles_fk", + "tableFrom": "articles_rels", + "tableTo": "articles", + "columnsFrom": [ + "articles_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "articles_rels_products_fk": { + "name": "articles_rels_products_fk", + "tableFrom": "articles_rels", + "tableTo": "products", + "columnsFrom": [ + "products_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public._articles_v": { + "name": "_articles_v", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "parent_id": { + "name": "parent_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "version_title": { + "name": "version_title", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "version_status": { + "name": "version_status", + "type": "enum__articles_v_version_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": false, + "default": "'draft'" + }, + "version_slug": { + "name": "version_slug", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "version_featured_image_id": { + "name": "version_featured_image_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "version_excerpt": { + "name": "version_excerpt", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "version_content": { + "name": "version_content", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "version_category": { + "name": "version_category", + "type": "enum__articles_v_version_category", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "version_featured": { + "name": "version_featured", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "version_author_id": { + "name": "version_author_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "version_published_at": { + "name": "version_published_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "version_meta_title": { + "name": "version_meta_title", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "version_meta_description": { + "name": "version_meta_description", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "version_updated_at": { + "name": "version_updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "version_created_at": { + "name": "version_created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "version__status": { + "name": "version__status", + "type": "enum__articles_v_version_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": false, + "default": "'draft'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "latest": { + "name": "latest", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "autosave": { + "name": "autosave", + "type": "boolean", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "_articles_v_parent_idx": { + "name": "_articles_v_parent_idx", + "columns": [ + { + "expression": "parent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "_articles_v_version_version_slug_idx": { + "name": "_articles_v_version_version_slug_idx", + "columns": [ + { + "expression": "version_slug", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "_articles_v_version_version_featured_image_idx": { + "name": "_articles_v_version_version_featured_image_idx", + "columns": [ + { + "expression": "version_featured_image_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "_articles_v_version_version_author_idx": { + "name": "_articles_v_version_version_author_idx", + "columns": [ + { + "expression": "version_author_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "_articles_v_version_version_updated_at_idx": { + "name": "_articles_v_version_version_updated_at_idx", + "columns": [ + { + "expression": "version_updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "_articles_v_version_version_created_at_idx": { + "name": "_articles_v_version_version_created_at_idx", + "columns": [ + { + "expression": "version_created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "_articles_v_version_version__status_idx": { + "name": "_articles_v_version_version__status_idx", + "columns": [ + { + "expression": "version__status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "_articles_v_created_at_idx": { + "name": "_articles_v_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "_articles_v_updated_at_idx": { + "name": "_articles_v_updated_at_idx", + "columns": [ + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "_articles_v_latest_idx": { + "name": "_articles_v_latest_idx", + "columns": [ + { + "expression": "latest", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "_articles_v_autosave_idx": { + "name": "_articles_v_autosave_idx", + "columns": [ + { + "expression": "autosave", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "_articles_v_parent_id_articles_id_fk": { + "name": "_articles_v_parent_id_articles_id_fk", + "tableFrom": "_articles_v", + "tableTo": "articles", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "_articles_v_version_featured_image_id_media_id_fk": { + "name": "_articles_v_version_featured_image_id_media_id_fk", + "tableFrom": "_articles_v", + "tableTo": "media", + "columnsFrom": [ + "version_featured_image_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "_articles_v_version_author_id_users_id_fk": { + "name": "_articles_v_version_author_id_users_id_fk", + "tableFrom": "_articles_v", + "tableTo": "users", + "columnsFrom": [ + "version_author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public._articles_v_texts": { + "name": "_articles_v_texts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "parent_id": { + "name": "parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "text": { + "name": "text", + "type": "varchar", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "_articles_v_texts_order_parent": { + "name": "_articles_v_texts_order_parent", + "columns": [ + { + "expression": "order", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "parent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "_articles_v_texts_parent_fk": { + "name": "_articles_v_texts_parent_fk", + "tableFrom": "_articles_v_texts", + "tableTo": "_articles_v", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public._articles_v_rels": { + "name": "_articles_v_rels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parent_id": { + "name": "parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "articles_id": { + "name": "articles_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "products_id": { + "name": "products_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "_articles_v_rels_order_idx": { + "name": "_articles_v_rels_order_idx", + "columns": [ + { + "expression": "order", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "_articles_v_rels_parent_idx": { + "name": "_articles_v_rels_parent_idx", + "columns": [ + { + "expression": "parent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "_articles_v_rels_path_idx": { + "name": "_articles_v_rels_path_idx", + "columns": [ + { + "expression": "path", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "_articles_v_rels_articles_id_idx": { + "name": "_articles_v_rels_articles_id_idx", + "columns": [ + { + "expression": "articles_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "_articles_v_rels_products_id_idx": { + "name": "_articles_v_rels_products_id_idx", + "columns": [ + { + "expression": "products_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "_articles_v_rels_parent_fk": { + "name": "_articles_v_rels_parent_fk", + "tableFrom": "_articles_v_rels", + "tableTo": "_articles_v", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "_articles_v_rels_articles_fk": { + "name": "_articles_v_rels_articles_fk", + "tableFrom": "_articles_v_rels", + "tableTo": "articles", + "columnsFrom": [ + "articles_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "_articles_v_rels_products_fk": { + "name": "_articles_v_rels_products_fk", + "tableFrom": "_articles_v_rels", + "tableTo": "products", + "columnsFrom": [ + "products_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.logs": { + "name": "logs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "action": { + "name": "action", + "type": "enum_logs_action", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "collection": { + "name": "collection", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "document_id": { + "name": "document_id", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "document_title": { + "name": "document_title", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "changes": { + "name": "changes", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "ip": { + "name": "ip", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "logs_collection_idx": { + "name": "logs_collection_idx", + "columns": [ + { + "expression": "collection", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "logs_document_id_idx": { + "name": "logs_document_id_idx", + "columns": [ + { + "expression": "document_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "logs_user_idx": { + "name": "logs_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "logs_updated_at_idx": { + "name": "logs_updated_at_idx", + "columns": [ + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "logs_created_at_idx": { + "name": "logs_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "logs_user_id_users_id_fk": { + "name": "logs_user_id_users_id_fk", + "tableFrom": "logs", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.disassembly_pages_components_linked_products": { + "name": "disassembly_pages_components_linked_products", + "schema": "", + "columns": { + "_order": { + "name": "_order", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "_parent_id": { + "name": "_parent_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "varchar", + "primaryKey": true, + "notNull": true + }, + "coordinate_x": { + "name": "coordinate_x", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "coordinate_y": { + "name": "coordinate_y", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "product_name": { + "name": "product_name", + "type": "varchar", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "disassembly_pages_components_linked_products_order_idx": { + "name": "disassembly_pages_components_linked_products_order_idx", + "columns": [ + { + "expression": "_order", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "disassembly_pages_components_linked_products_parent_id_idx": { + "name": "disassembly_pages_components_linked_products_parent_id_idx", + "columns": [ + { + "expression": "_parent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "disassembly_pages_components_linked_products_parent_id_fk": { + "name": "disassembly_pages_components_linked_products_parent_id_fk", + "tableFrom": "disassembly_pages_components_linked_products", + "tableTo": "disassembly_pages_components", + "columnsFrom": [ + "_parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.disassembly_pages_components": { + "name": "disassembly_pages_components", + "schema": "", + "columns": { + "_order": { + "name": "_order", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "_parent_id": { + "name": "_parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "varchar", + "primaryKey": true, + "notNull": true + }, + "label": { + "name": "label", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "start_coordinate_x": { + "name": "start_coordinate_x", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "start_coordinate_y": { + "name": "start_coordinate_y", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "start_radius": { + "name": "start_radius", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": 20 + } + }, + "indexes": { + "disassembly_pages_components_order_idx": { + "name": "disassembly_pages_components_order_idx", + "columns": [ + { + "expression": "_order", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "disassembly_pages_components_parent_id_idx": { + "name": "disassembly_pages_components_parent_id_idx", + "columns": [ + { + "expression": "_parent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "disassembly_pages_components_parent_id_fk": { + "name": "disassembly_pages_components_parent_id_fk", + "tableFrom": "disassembly_pages_components", + "tableTo": "disassembly_pages", + "columnsFrom": [ + "_parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.disassembly_pages": { + "name": "disassembly_pages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "main_image_id": { + "name": "main_image_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "url": { + "name": "url", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "disassembly_pages_main_image_idx": { + "name": "disassembly_pages_main_image_idx", + "columns": [ + { + "expression": "main_image_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "disassembly_pages_updated_at_idx": { + "name": "disassembly_pages_updated_at_idx", + "columns": [ + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "disassembly_pages_created_at_idx": { + "name": "disassembly_pages_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "disassembly_pages_main_image_id_media_id_fk": { + "name": "disassembly_pages_main_image_id_media_id_fk", + "tableFrom": "disassembly_pages", + "tableTo": "media", + "columnsFrom": [ + "main_image_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.disassembly_pages_rels": { + "name": "disassembly_pages_rels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parent_id": { + "name": "parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "products_id": { + "name": "products_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "preorder_products_id": { + "name": "preorder_products_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "disassembly_pages_rels_order_idx": { + "name": "disassembly_pages_rels_order_idx", + "columns": [ + { + "expression": "order", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "disassembly_pages_rels_parent_idx": { + "name": "disassembly_pages_rels_parent_idx", + "columns": [ + { + "expression": "parent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "disassembly_pages_rels_path_idx": { + "name": "disassembly_pages_rels_path_idx", + "columns": [ + { + "expression": "path", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "disassembly_pages_rels_products_id_idx": { + "name": "disassembly_pages_rels_products_id_idx", + "columns": [ + { + "expression": "products_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "disassembly_pages_rels_preorder_products_id_idx": { + "name": "disassembly_pages_rels_preorder_products_id_idx", + "columns": [ + { + "expression": "preorder_products_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "disassembly_pages_rels_parent_fk": { + "name": "disassembly_pages_rels_parent_fk", + "tableFrom": "disassembly_pages_rels", + "tableTo": "disassembly_pages", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "disassembly_pages_rels_products_fk": { + "name": "disassembly_pages_rels_products_fk", + "tableFrom": "disassembly_pages_rels", + "tableTo": "products", + "columnsFrom": [ + "products_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "disassembly_pages_rels_preorder_products_fk": { + "name": "disassembly_pages_rels_preorder_products_fk", + "tableFrom": "disassembly_pages_rels", + "tableTo": "preorder_products", + "columnsFrom": [ + "preorder_products_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.payload_kv": { + "name": "payload_kv", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "key": { + "name": "key", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "jsonb", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "payload_kv_key_idx": { + "name": "payload_kv_key_idx", + "columns": [ + { + "expression": "key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.payload_jobs_log": { + "name": "payload_jobs_log", + "schema": "", + "columns": { + "_order": { + "name": "_order", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "_parent_id": { + "name": "_parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "varchar", + "primaryKey": true, + "notNull": true + }, + "executed_at": { + "name": "executed_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true + }, + "task_slug": { + "name": "task_slug", + "type": "enum_payload_jobs_log_task_slug", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "task_i_d": { + "name": "task_i_d", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "input": { + "name": "input", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "output": { + "name": "output", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "state": { + "name": "state", + "type": "enum_payload_jobs_log_state", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "error": { + "name": "error", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "payload_jobs_log_order_idx": { + "name": "payload_jobs_log_order_idx", + "columns": [ + { + "expression": "_order", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "payload_jobs_log_parent_id_idx": { + "name": "payload_jobs_log_parent_id_idx", + "columns": [ + { + "expression": "_parent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "payload_jobs_log_parent_id_fk": { + "name": "payload_jobs_log_parent_id_fk", + "tableFrom": "payload_jobs_log", + "tableTo": "payload_jobs", + "columnsFrom": [ + "_parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.payload_jobs": { + "name": "payload_jobs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "input": { + "name": "input", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "total_tried": { + "name": "total_tried", + "type": "numeric", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "has_error": { + "name": "has_error", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "error": { + "name": "error", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "task_slug": { + "name": "task_slug", + "type": "enum_payload_jobs_task_slug", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "queue": { + "name": "queue", + "type": "varchar", + "primaryKey": false, + "notNull": false, + "default": "'default'" + }, + "wait_until": { + "name": "wait_until", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "processing": { + "name": "processing", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "payload_jobs_completed_at_idx": { + "name": "payload_jobs_completed_at_idx", + "columns": [ + { + "expression": "completed_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "payload_jobs_total_tried_idx": { + "name": "payload_jobs_total_tried_idx", + "columns": [ + { + "expression": "total_tried", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "payload_jobs_has_error_idx": { + "name": "payload_jobs_has_error_idx", + "columns": [ + { + "expression": "has_error", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "payload_jobs_task_slug_idx": { + "name": "payload_jobs_task_slug_idx", + "columns": [ + { + "expression": "task_slug", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "payload_jobs_queue_idx": { + "name": "payload_jobs_queue_idx", + "columns": [ + { + "expression": "queue", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "payload_jobs_wait_until_idx": { + "name": "payload_jobs_wait_until_idx", + "columns": [ + { + "expression": "wait_until", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "payload_jobs_processing_idx": { + "name": "payload_jobs_processing_idx", + "columns": [ + { + "expression": "processing", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "payload_jobs_updated_at_idx": { + "name": "payload_jobs_updated_at_idx", + "columns": [ + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "payload_jobs_created_at_idx": { + "name": "payload_jobs_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.payload_locked_documents": { + "name": "payload_locked_documents", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "global_slug": { + "name": "global_slug", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "payload_locked_documents_global_slug_idx": { + "name": "payload_locked_documents_global_slug_idx", + "columns": [ + { + "expression": "global_slug", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "payload_locked_documents_updated_at_idx": { + "name": "payload_locked_documents_updated_at_idx", + "columns": [ + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "payload_locked_documents_created_at_idx": { + "name": "payload_locked_documents_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.payload_locked_documents_rels": { + "name": "payload_locked_documents_rels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parent_id": { + "name": "parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "users_id": { + "name": "users_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "media_id": { + "name": "media_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "products_id": { + "name": "products_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "preorder_products_id": { + "name": "preorder_products_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "announcements_id": { + "name": "announcements_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "articles_id": { + "name": "articles_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "logs_id": { + "name": "logs_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "disassembly_pages_id": { + "name": "disassembly_pages_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "payload_locked_documents_rels_order_idx": { + "name": "payload_locked_documents_rels_order_idx", + "columns": [ + { + "expression": "order", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "payload_locked_documents_rels_parent_idx": { + "name": "payload_locked_documents_rels_parent_idx", + "columns": [ + { + "expression": "parent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "payload_locked_documents_rels_path_idx": { + "name": "payload_locked_documents_rels_path_idx", + "columns": [ + { + "expression": "path", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "payload_locked_documents_rels_users_id_idx": { + "name": "payload_locked_documents_rels_users_id_idx", + "columns": [ + { + "expression": "users_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "payload_locked_documents_rels_media_id_idx": { + "name": "payload_locked_documents_rels_media_id_idx", + "columns": [ + { + "expression": "media_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "payload_locked_documents_rels_products_id_idx": { + "name": "payload_locked_documents_rels_products_id_idx", + "columns": [ + { + "expression": "products_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "payload_locked_documents_rels_preorder_products_id_idx": { + "name": "payload_locked_documents_rels_preorder_products_id_idx", + "columns": [ + { + "expression": "preorder_products_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "payload_locked_documents_rels_announcements_id_idx": { + "name": "payload_locked_documents_rels_announcements_id_idx", + "columns": [ + { + "expression": "announcements_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "payload_locked_documents_rels_articles_id_idx": { + "name": "payload_locked_documents_rels_articles_id_idx", + "columns": [ + { + "expression": "articles_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "payload_locked_documents_rels_logs_id_idx": { + "name": "payload_locked_documents_rels_logs_id_idx", + "columns": [ + { + "expression": "logs_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "payload_locked_documents_rels_disassembly_pages_id_idx": { + "name": "payload_locked_documents_rels_disassembly_pages_id_idx", + "columns": [ + { + "expression": "disassembly_pages_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "payload_locked_documents_rels_parent_fk": { + "name": "payload_locked_documents_rels_parent_fk", + "tableFrom": "payload_locked_documents_rels", + "tableTo": "payload_locked_documents", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "payload_locked_documents_rels_users_fk": { + "name": "payload_locked_documents_rels_users_fk", + "tableFrom": "payload_locked_documents_rels", + "tableTo": "users", + "columnsFrom": [ + "users_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "payload_locked_documents_rels_media_fk": { + "name": "payload_locked_documents_rels_media_fk", + "tableFrom": "payload_locked_documents_rels", + "tableTo": "media", + "columnsFrom": [ + "media_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "payload_locked_documents_rels_products_fk": { + "name": "payload_locked_documents_rels_products_fk", + "tableFrom": "payload_locked_documents_rels", + "tableTo": "products", + "columnsFrom": [ + "products_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "payload_locked_documents_rels_preorder_products_fk": { + "name": "payload_locked_documents_rels_preorder_products_fk", + "tableFrom": "payload_locked_documents_rels", + "tableTo": "preorder_products", + "columnsFrom": [ + "preorder_products_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "payload_locked_documents_rels_announcements_fk": { + "name": "payload_locked_documents_rels_announcements_fk", + "tableFrom": "payload_locked_documents_rels", + "tableTo": "announcements", + "columnsFrom": [ + "announcements_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "payload_locked_documents_rels_articles_fk": { + "name": "payload_locked_documents_rels_articles_fk", + "tableFrom": "payload_locked_documents_rels", + "tableTo": "articles", + "columnsFrom": [ + "articles_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "payload_locked_documents_rels_logs_fk": { + "name": "payload_locked_documents_rels_logs_fk", + "tableFrom": "payload_locked_documents_rels", + "tableTo": "logs", + "columnsFrom": [ + "logs_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "payload_locked_documents_rels_disassembly_pages_fk": { + "name": "payload_locked_documents_rels_disassembly_pages_fk", + "tableFrom": "payload_locked_documents_rels", + "tableTo": "disassembly_pages", + "columnsFrom": [ + "disassembly_pages_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.payload_preferences": { + "name": "payload_preferences", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "key": { + "name": "key", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "payload_preferences_key_idx": { + "name": "payload_preferences_key_idx", + "columns": [ + { + "expression": "key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "payload_preferences_updated_at_idx": { + "name": "payload_preferences_updated_at_idx", + "columns": [ + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "payload_preferences_created_at_idx": { + "name": "payload_preferences_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.payload_preferences_rels": { + "name": "payload_preferences_rels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parent_id": { + "name": "parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "users_id": { + "name": "users_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "payload_preferences_rels_order_idx": { + "name": "payload_preferences_rels_order_idx", + "columns": [ + { + "expression": "order", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "payload_preferences_rels_parent_idx": { + "name": "payload_preferences_rels_parent_idx", + "columns": [ + { + "expression": "parent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "payload_preferences_rels_path_idx": { + "name": "payload_preferences_rels_path_idx", + "columns": [ + { + "expression": "path", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "payload_preferences_rels_users_id_idx": { + "name": "payload_preferences_rels_users_id_idx", + "columns": [ + { + "expression": "users_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "payload_preferences_rels_parent_fk": { + "name": "payload_preferences_rels_parent_fk", + "tableFrom": "payload_preferences_rels", + "tableTo": "payload_preferences", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "payload_preferences_rels_users_fk": { + "name": "payload_preferences_rels_users_fk", + "tableFrom": "payload_preferences_rels", + "tableTo": "users", + "columnsFrom": [ + "users_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.payload_migrations": { + "name": "payload_migrations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "batch": { + "name": "batch", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "payload_migrations_updated_at_idx": { + "name": "payload_migrations_updated_at_idx", + "columns": [ + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "payload_migrations_created_at_idx": { + "name": "payload_migrations_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.admin_settings": { + "name": "admin_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar", + "primaryKey": false, + "notNull": false, + "default": "'管理员设置'" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.logs_manager": { + "name": "logs_manager", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "placeholder": { + "name": "placeholder", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hero_slider_slides": { + "name": "hero_slider_slides", + "schema": "", + "columns": { + "_order": { + "name": "_order", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "_parent_id": { + "name": "_parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "varchar", + "primaryKey": true, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "subtitle": { + "name": "subtitle", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "desc": { + "name": "desc", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "image_id": { + "name": "image_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "layout": { + "name": "layout", + "type": "enum_hero_slider_slides_layout", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'left'" + }, + "show_focus_circle": { + "name": "show_focus_circle", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "price": { + "name": "price", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "link": { + "name": "link", + "type": "varchar", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "hero_slider_slides_order_idx": { + "name": "hero_slider_slides_order_idx", + "columns": [ + { + "expression": "_order", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "hero_slider_slides_parent_id_idx": { + "name": "hero_slider_slides_parent_id_idx", + "columns": [ + { + "expression": "_parent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "hero_slider_slides_image_idx": { + "name": "hero_slider_slides_image_idx", + "columns": [ + { + "expression": "image_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "hero_slider_slides_image_id_media_id_fk": { + "name": "hero_slider_slides_image_id_media_id_fk", + "tableFrom": "hero_slider_slides", + "tableTo": "media", + "columnsFrom": [ + "image_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "hero_slider_slides_parent_id_fk": { + "name": "hero_slider_slides_parent_id_fk", + "tableFrom": "hero_slider_slides", + "tableTo": "hero_slider", + "columnsFrom": [ + "_parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hero_slider": { + "name": "hero_slider", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hero_slider_rels": { + "name": "hero_slider_rels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parent_id": { + "name": "parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "products_id": { + "name": "products_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "preorder_products_id": { + "name": "preorder_products_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "hero_slider_rels_order_idx": { + "name": "hero_slider_rels_order_idx", + "columns": [ + { + "expression": "order", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "hero_slider_rels_parent_idx": { + "name": "hero_slider_rels_parent_idx", + "columns": [ + { + "expression": "parent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "hero_slider_rels_path_idx": { + "name": "hero_slider_rels_path_idx", + "columns": [ + { + "expression": "path", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "hero_slider_rels_products_id_idx": { + "name": "hero_slider_rels_products_id_idx", + "columns": [ + { + "expression": "products_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "hero_slider_rels_preorder_products_id_idx": { + "name": "hero_slider_rels_preorder_products_id_idx", + "columns": [ + { + "expression": "preorder_products_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "hero_slider_rels_parent_fk": { + "name": "hero_slider_rels_parent_fk", + "tableFrom": "hero_slider_rels", + "tableTo": "hero_slider", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "hero_slider_rels_products_fk": { + "name": "hero_slider_rels_products_fk", + "tableFrom": "hero_slider_rels", + "tableTo": "products", + "columnsFrom": [ + "products_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "hero_slider_rels_preorder_products_fk": { + "name": "hero_slider_rels_preorder_products_fk", + "tableFrom": "hero_slider_rels", + "tableTo": "preorder_products", + "columnsFrom": [ + "preorder_products_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.product_recommendations_lists": { + "name": "product_recommendations_lists", + "schema": "", + "columns": { + "_order": { + "name": "_order", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "_parent_id": { + "name": "_parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "varchar", + "primaryKey": true, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "subtitle": { + "name": "subtitle", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "preorder": { + "name": "preorder", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + } + }, + "indexes": { + "product_recommendations_lists_order_idx": { + "name": "product_recommendations_lists_order_idx", + "columns": [ + { + "expression": "_order", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "product_recommendations_lists_parent_id_idx": { + "name": "product_recommendations_lists_parent_id_idx", + "columns": [ + { + "expression": "_parent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "product_recommendations_lists_parent_id_fk": { + "name": "product_recommendations_lists_parent_id_fk", + "tableFrom": "product_recommendations_lists", + "tableTo": "product_recommendations", + "columnsFrom": [ + "_parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.product_recommendations": { + "name": "product_recommendations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.product_recommendations_rels": { + "name": "product_recommendations_rels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parent_id": { + "name": "parent_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "products_id": { + "name": "products_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "preorder_products_id": { + "name": "preorder_products_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "product_recommendations_rels_order_idx": { + "name": "product_recommendations_rels_order_idx", + "columns": [ + { + "expression": "order", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "product_recommendations_rels_parent_idx": { + "name": "product_recommendations_rels_parent_idx", + "columns": [ + { + "expression": "parent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "product_recommendations_rels_path_idx": { + "name": "product_recommendations_rels_path_idx", + "columns": [ + { + "expression": "path", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "product_recommendations_rels_products_id_idx": { + "name": "product_recommendations_rels_products_id_idx", + "columns": [ + { + "expression": "products_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "product_recommendations_rels_preorder_products_id_idx": { + "name": "product_recommendations_rels_preorder_products_id_idx", + "columns": [ + { + "expression": "preorder_products_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "product_recommendations_rels_parent_fk": { + "name": "product_recommendations_rels_parent_fk", + "tableFrom": "product_recommendations_rels", + "tableTo": "product_recommendations", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "product_recommendations_rels_products_fk": { + "name": "product_recommendations_rels_products_fk", + "tableFrom": "product_recommendations_rels", + "tableTo": "products", + "columnsFrom": [ + "products_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "product_recommendations_rels_preorder_products_fk": { + "name": "product_recommendations_rels_preorder_products_fk", + "tableFrom": "product_recommendations_rels", + "tableTo": "preorder_products", + "columnsFrom": [ + "preorder_products_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.site_access": { + "name": "site_access", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "is_accessible": { + "name": "is_accessible", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "maintenance_message": { + "name": "maintenance_message", + "type": "varchar", + "primaryKey": false, + "notNull": true, + "default": "'The site is currently under maintenance. Please check back later.'" + }, + "estimated_restore_time": { + "name": "estimated_restore_time", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3) with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.enum_users_roles": { + "name": "enum_users_roles", + "schema": "public", + "values": [ + "admin", + "editor", + "user" + ] + }, + "public.enum_products_status": { + "name": "enum_products_status", + "schema": "public", + "values": [ + "draft", + "published" + ] + }, + "public.enum_preorder_products_status": { + "name": "enum_preorder_products_status", + "schema": "public", + "values": [ + "draft", + "published" + ] + }, + "public.enum_preorder_products_preorder_type": { + "name": "enum_preorder_products_preorder_type", + "schema": "public", + "values": [ + "standard", + "crowdfunding", + "limited" + ] + }, + "public.enum_announcements_type": { + "name": "enum_announcements_type", + "schema": "public", + "values": [ + "info", + "warning", + "important", + "urgent" + ] + }, + "public.enum_announcements_status": { + "name": "enum_announcements_status", + "schema": "public", + "values": [ + "draft", + "published", + "archived" + ] + }, + "public.enum_articles_status": { + "name": "enum_articles_status", + "schema": "public", + "values": [ + "draft", + "published" + ] + }, + "public.enum_articles_category": { + "name": "enum_articles_category", + "schema": "public", + "values": [ + "news", + "tutorial", + "tech", + "review", + "industry", + "other" + ] + }, + "public.enum__articles_v_version_status": { + "name": "enum__articles_v_version_status", + "schema": "public", + "values": [ + "draft", + "published" + ] + }, + "public.enum__articles_v_version_category": { + "name": "enum__articles_v_version_category", + "schema": "public", + "values": [ + "news", + "tutorial", + "tech", + "review", + "industry", + "other" + ] + }, + "public.enum_logs_action": { + "name": "enum_logs_action", + "schema": "public", + "values": [ + "create", + "update", + "delete", + "sync", + "login", + "logout" + ] + }, + "public.enum_payload_jobs_log_task_slug": { + "name": "enum_payload_jobs_log_task_slug", + "schema": "public", + "values": [ + "inline", + "schedulePublish" + ] + }, + "public.enum_payload_jobs_log_state": { + "name": "enum_payload_jobs_log_state", + "schema": "public", + "values": [ + "failed", + "succeeded" + ] + }, + "public.enum_payload_jobs_task_slug": { + "name": "enum_payload_jobs_task_slug", + "schema": "public", + "values": [ + "inline", + "schedulePublish" + ] + }, + "public.enum_hero_slider_slides_layout": { + "name": "enum_hero_slider_slides_layout", + "schema": "public", + "values": [ + "left", + "right", + "center" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "id": "96d223f3-995a-47b2-8e70-c4ccf3483b2f", + "prevId": "00000000-0000-0000-0000-000000000000" +} \ No newline at end of file diff --git a/src/migrations/20260222_170233.ts b/src/migrations/20260222_170233.ts new file mode 100644 index 0000000..56226b4 --- /dev/null +++ b/src/migrations/20260222_170233.ts @@ -0,0 +1,314 @@ +import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres' + +export async function up({ db, payload, req }: MigrateUpArgs): Promise { + await db.execute(sql` + CREATE TYPE "public"."enum_preorder_products_preorder_type" AS ENUM('standard', 'crowdfunding', 'limited'); + CREATE TYPE "public"."enum_hero_slider_slides_layout" AS ENUM('left', 'right', 'center'); + CREATE TABLE "products_taobao_links" ( + "_order" integer NOT NULL, + "_parent_id" integer NOT NULL, + "id" varchar PRIMARY KEY NOT NULL, + "url" varchar NOT NULL, + "title" varchar, + "thumbnail" varchar, + "note" varchar + ); + + CREATE TABLE "preorder_products_taobao_links" ( + "_order" integer NOT NULL, + "_parent_id" integer NOT NULL, + "id" varchar PRIMARY KEY NOT NULL, + "url" varchar NOT NULL, + "title" varchar, + "thumbnail" varchar, + "note" varchar + ); + + CREATE TABLE "disassembly_pages_components_linked_products" ( + "_order" integer NOT NULL, + "_parent_id" varchar NOT NULL, + "id" varchar PRIMARY KEY NOT NULL, + "coordinate_x" numeric DEFAULT 0 NOT NULL, + "coordinate_y" numeric DEFAULT 0 NOT NULL, + "product_name" varchar + ); + + CREATE TABLE "disassembly_pages_components" ( + "_order" integer NOT NULL, + "_parent_id" integer NOT NULL, + "id" varchar PRIMARY KEY NOT NULL, + "label" varchar, + "start_coordinate_x" numeric DEFAULT 0 NOT NULL, + "start_coordinate_y" numeric DEFAULT 0 NOT NULL, + "start_radius" numeric DEFAULT 20 NOT NULL + ); + + CREATE TABLE "disassembly_pages" ( + "id" serial PRIMARY KEY NOT NULL, + "main_image_id" integer NOT NULL, + "name" varchar NOT NULL, + "url" varchar, + "updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL, + "created_at" timestamp(3) with time zone DEFAULT now() NOT NULL + ); + + CREATE TABLE "disassembly_pages_rels" ( + "id" serial PRIMARY KEY NOT NULL, + "order" integer, + "parent_id" integer NOT NULL, + "path" varchar NOT NULL, + "products_id" integer, + "preorder_products_id" integer + ); + + CREATE TABLE "hero_slider_rels" ( + "id" serial PRIMARY KEY NOT NULL, + "order" integer, + "parent_id" integer NOT NULL, + "path" varchar NOT NULL, + "products_id" integer, + "preorder_products_id" integer + ); + + CREATE TABLE "site_access" ( + "id" serial PRIMARY KEY NOT NULL, + "is_accessible" boolean DEFAULT true NOT NULL, + "maintenance_message" varchar DEFAULT 'The site is currently under maintenance. Please check back later.' NOT NULL, + "estimated_restore_time" timestamp(3) with time zone, + "updated_at" timestamp(3) with time zone, + "created_at" timestamp(3) with time zone + ); + + ALTER TABLE "order_products" DISABLE ROW LEVEL SECURITY; + ALTER TABLE "order_products_rels" DISABLE ROW LEVEL SECURITY; + DROP TABLE "order_products" CASCADE; + DROP TABLE "order_products_rels" CASCADE; + ALTER TABLE "preorder_products_rels" DROP CONSTRAINT "preorder_products_rels_order_products_fk"; + + ALTER TABLE "payload_locked_documents_rels" DROP CONSTRAINT "payload_locked_documents_rels_order_products_fk"; + + ALTER TABLE "hero_slider_slides" DROP CONSTRAINT "hero_slider_slides_image_mobile_id_media_id_fk"; + + ALTER TABLE "product_recommendations_rels" DROP CONSTRAINT "product_recommendations_rels_order_products_fk"; + + DROP INDEX "preorder_products_rels_order_products_id_idx"; + DROP INDEX "payload_locked_documents_rels_order_products_id_idx"; + DROP INDEX "hero_slider_slides_image_mobile_idx"; + DROP INDEX "product_recommendations_rels_order_products_id_idx"; + ALTER TABLE "preorder_products" ALTER COLUMN "description" SET DATA TYPE varchar; + ALTER TABLE "hero_slider_slides" ALTER COLUMN "subtitle" SET NOT NULL; + ALTER TABLE "products" ADD COLUMN "seed_id" varchar; + ALTER TABLE "products" ADD COLUMN "start_price" numeric; + ALTER TABLE "products" ADD COLUMN "description" varchar; + ALTER TABLE "products" ADD COLUMN "tags" varchar; + ALTER TABLE "products" ADD COLUMN "type" varchar; + ALTER TABLE "products" ADD COLUMN "collection" varchar; + ALTER TABLE "products" ADD COLUMN "category" varchar; + ALTER TABLE "products" ADD COLUMN "height" numeric; + ALTER TABLE "products" ADD COLUMN "width" numeric; + ALTER TABLE "products" ADD COLUMN "length" numeric; + ALTER TABLE "products" ADD COLUMN "weight" numeric; + ALTER TABLE "products" ADD COLUMN "mid_code" varchar; + ALTER TABLE "products" ADD COLUMN "hs_code" varchar; + ALTER TABLE "products" ADD COLUMN "country_of_origin" varchar; + ALTER TABLE "products_rels" ADD COLUMN "preorder_products_id" integer; + ALTER TABLE "preorder_products" ADD COLUMN "seed_id" varchar; + ALTER TABLE "preorder_products" ADD COLUMN "start_price" numeric; + ALTER TABLE "preorder_products" ADD COLUMN "preorder_type" "enum_preorder_products_preorder_type" DEFAULT 'standard' NOT NULL; + ALTER TABLE "preorder_products" ADD COLUMN "funding_goal" numeric DEFAULT 0 NOT NULL; + ALTER TABLE "preorder_products" ADD COLUMN "preorder_start_date" timestamp(3) with time zone; + ALTER TABLE "preorder_products" ADD COLUMN "preorder_end_date" timestamp(3) with time zone; + ALTER TABLE "preorder_products" ADD COLUMN "order_count" numeric DEFAULT 0; + ALTER TABLE "preorder_products" ADD COLUMN "fake_order_count" numeric DEFAULT 0; + ALTER TABLE "preorder_products" ADD COLUMN "content" jsonb; + ALTER TABLE "preorder_products" ADD COLUMN "tags" varchar; + ALTER TABLE "preorder_products" ADD COLUMN "type" varchar; + ALTER TABLE "preorder_products" ADD COLUMN "collection" varchar; + ALTER TABLE "preorder_products" ADD COLUMN "category" varchar; + ALTER TABLE "preorder_products" ADD COLUMN "height" numeric; + ALTER TABLE "preorder_products" ADD COLUMN "width" numeric; + ALTER TABLE "preorder_products" ADD COLUMN "length" numeric; + ALTER TABLE "preorder_products" ADD COLUMN "weight" numeric; + ALTER TABLE "preorder_products" ADD COLUMN "mid_code" varchar; + ALTER TABLE "preorder_products" ADD COLUMN "hs_code" varchar; + ALTER TABLE "preorder_products" ADD COLUMN "country_of_origin" varchar; + ALTER TABLE "preorder_products_rels" ADD COLUMN "products_id" integer; + ALTER TABLE "payload_locked_documents_rels" ADD COLUMN "disassembly_pages_id" integer; + ALTER TABLE "hero_slider_slides" ADD COLUMN "desc" varchar NOT NULL; + ALTER TABLE "hero_slider_slides" ADD COLUMN "layout" "enum_hero_slider_slides_layout" DEFAULT 'left' NOT NULL; + ALTER TABLE "hero_slider_slides" ADD COLUMN "show_focus_circle" boolean DEFAULT false; + ALTER TABLE "hero_slider_slides" ADD COLUMN "price" varchar NOT NULL; + ALTER TABLE "product_recommendations_lists" ADD COLUMN "preorder" boolean DEFAULT false; + ALTER TABLE "products_taobao_links" ADD CONSTRAINT "products_taobao_links_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."products"("id") ON DELETE cascade ON UPDATE no action; + ALTER TABLE "preorder_products_taobao_links" ADD CONSTRAINT "preorder_products_taobao_links_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."preorder_products"("id") ON DELETE cascade ON UPDATE no action; + ALTER TABLE "disassembly_pages_components_linked_products" ADD CONSTRAINT "disassembly_pages_components_linked_products_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."disassembly_pages_components"("id") ON DELETE cascade ON UPDATE no action; + ALTER TABLE "disassembly_pages_components" ADD CONSTRAINT "disassembly_pages_components_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."disassembly_pages"("id") ON DELETE cascade ON UPDATE no action; + ALTER TABLE "disassembly_pages" ADD CONSTRAINT "disassembly_pages_main_image_id_media_id_fk" FOREIGN KEY ("main_image_id") REFERENCES "public"."media"("id") ON DELETE set null ON UPDATE no action; + ALTER TABLE "disassembly_pages_rels" ADD CONSTRAINT "disassembly_pages_rels_parent_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."disassembly_pages"("id") ON DELETE cascade ON UPDATE no action; + ALTER TABLE "disassembly_pages_rels" ADD CONSTRAINT "disassembly_pages_rels_products_fk" FOREIGN KEY ("products_id") REFERENCES "public"."products"("id") ON DELETE cascade ON UPDATE no action; + ALTER TABLE "disassembly_pages_rels" ADD CONSTRAINT "disassembly_pages_rels_preorder_products_fk" FOREIGN KEY ("preorder_products_id") REFERENCES "public"."preorder_products"("id") ON DELETE cascade ON UPDATE no action; + ALTER TABLE "hero_slider_rels" ADD CONSTRAINT "hero_slider_rels_parent_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."hero_slider"("id") ON DELETE cascade ON UPDATE no action; + ALTER TABLE "hero_slider_rels" ADD CONSTRAINT "hero_slider_rels_products_fk" FOREIGN KEY ("products_id") REFERENCES "public"."products"("id") ON DELETE cascade ON UPDATE no action; + ALTER TABLE "hero_slider_rels" ADD CONSTRAINT "hero_slider_rels_preorder_products_fk" FOREIGN KEY ("preorder_products_id") REFERENCES "public"."preorder_products"("id") ON DELETE cascade ON UPDATE no action; + CREATE INDEX "products_taobao_links_order_idx" ON "products_taobao_links" USING btree ("_order"); + CREATE INDEX "products_taobao_links_parent_id_idx" ON "products_taobao_links" USING btree ("_parent_id"); + CREATE INDEX "preorder_products_taobao_links_order_idx" ON "preorder_products_taobao_links" USING btree ("_order"); + CREATE INDEX "preorder_products_taobao_links_parent_id_idx" ON "preorder_products_taobao_links" USING btree ("_parent_id"); + CREATE INDEX "disassembly_pages_components_linked_products_order_idx" ON "disassembly_pages_components_linked_products" USING btree ("_order"); + CREATE INDEX "disassembly_pages_components_linked_products_parent_id_idx" ON "disassembly_pages_components_linked_products" USING btree ("_parent_id"); + CREATE INDEX "disassembly_pages_components_order_idx" ON "disassembly_pages_components" USING btree ("_order"); + CREATE INDEX "disassembly_pages_components_parent_id_idx" ON "disassembly_pages_components" USING btree ("_parent_id"); + CREATE INDEX "disassembly_pages_main_image_idx" ON "disassembly_pages" USING btree ("main_image_id"); + CREATE INDEX "disassembly_pages_updated_at_idx" ON "disassembly_pages" USING btree ("updated_at"); + CREATE INDEX "disassembly_pages_created_at_idx" ON "disassembly_pages" USING btree ("created_at"); + CREATE INDEX "disassembly_pages_rels_order_idx" ON "disassembly_pages_rels" USING btree ("order"); + CREATE INDEX "disassembly_pages_rels_parent_idx" ON "disassembly_pages_rels" USING btree ("parent_id"); + CREATE INDEX "disassembly_pages_rels_path_idx" ON "disassembly_pages_rels" USING btree ("path"); + CREATE INDEX "disassembly_pages_rels_products_id_idx" ON "disassembly_pages_rels" USING btree ("products_id"); + CREATE INDEX "disassembly_pages_rels_preorder_products_id_idx" ON "disassembly_pages_rels" USING btree ("preorder_products_id"); + CREATE INDEX "hero_slider_rels_order_idx" ON "hero_slider_rels" USING btree ("order"); + CREATE INDEX "hero_slider_rels_parent_idx" ON "hero_slider_rels" USING btree ("parent_id"); + CREATE INDEX "hero_slider_rels_path_idx" ON "hero_slider_rels" USING btree ("path"); + CREATE INDEX "hero_slider_rels_products_id_idx" ON "hero_slider_rels" USING btree ("products_id"); + CREATE INDEX "hero_slider_rels_preorder_products_id_idx" ON "hero_slider_rels" USING btree ("preorder_products_id"); + ALTER TABLE "products_rels" ADD CONSTRAINT "products_rels_preorder_products_fk" FOREIGN KEY ("preorder_products_id") REFERENCES "public"."preorder_products"("id") ON DELETE cascade ON UPDATE no action; + ALTER TABLE "preorder_products_rels" ADD CONSTRAINT "preorder_products_rels_products_fk" FOREIGN KEY ("products_id") REFERENCES "public"."products"("id") ON DELETE cascade ON UPDATE no action; + ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_disassembly_pages_fk" FOREIGN KEY ("disassembly_pages_id") REFERENCES "public"."disassembly_pages"("id") ON DELETE cascade ON UPDATE no action; + CREATE INDEX "products_handle_idx" ON "products" USING btree ("handle"); + CREATE UNIQUE INDEX "products_seed_id_idx" ON "products" USING btree ("seed_id"); + CREATE INDEX "products_rels_preorder_products_id_idx" ON "products_rels" USING btree ("preorder_products_id"); + CREATE INDEX "preorder_products_handle_idx" ON "preorder_products" USING btree ("handle"); + CREATE UNIQUE INDEX "preorder_products_seed_id_idx" ON "preorder_products" USING btree ("seed_id"); + CREATE INDEX "preorder_products_rels_products_id_idx" ON "preorder_products_rels" USING btree ("products_id"); + CREATE INDEX "payload_locked_documents_rels_disassembly_pages_id_idx" ON "payload_locked_documents_rels" USING btree ("disassembly_pages_id"); + ALTER TABLE "preorder_products_rels" DROP COLUMN "order_products_id"; + ALTER TABLE "payload_locked_documents_rels" DROP COLUMN "order_products_id"; + ALTER TABLE "hero_slider_slides" DROP COLUMN "image_mobile_id"; + ALTER TABLE "product_recommendations_rels" DROP COLUMN "order_products_id"; + DROP TYPE "public"."enum_order_products_status";`) +} + +export async function down({ db, payload, req }: MigrateDownArgs): Promise { + await db.execute(sql` + CREATE TYPE "public"."enum_order_products_status" AS ENUM('draft', 'published'); + CREATE TABLE "order_products" ( + "id" serial PRIMARY KEY NOT NULL, + "medusa_id" varchar NOT NULL, + "status" "enum_order_products_status" DEFAULT 'draft' NOT NULL, + "title" varchar NOT NULL, + "handle" varchar, + "thumbnail" varchar, + "last_synced_at" timestamp(3) with time zone, + "description" jsonb, + "updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL, + "created_at" timestamp(3) with time zone DEFAULT now() NOT NULL + ); + + CREATE TABLE "order_products_rels" ( + "id" serial PRIMARY KEY NOT NULL, + "order" integer, + "parent_id" integer NOT NULL, + "path" varchar NOT NULL, + "preorder_products_id" integer, + "order_products_id" integer + ); + + ALTER TABLE "products_taobao_links" DISABLE ROW LEVEL SECURITY; + ALTER TABLE "preorder_products_taobao_links" DISABLE ROW LEVEL SECURITY; + ALTER TABLE "disassembly_pages_components_linked_products" DISABLE ROW LEVEL SECURITY; + ALTER TABLE "disassembly_pages_components" DISABLE ROW LEVEL SECURITY; + ALTER TABLE "disassembly_pages" DISABLE ROW LEVEL SECURITY; + ALTER TABLE "disassembly_pages_rels" DISABLE ROW LEVEL SECURITY; + ALTER TABLE "hero_slider_rels" DISABLE ROW LEVEL SECURITY; + ALTER TABLE "site_access" DISABLE ROW LEVEL SECURITY; + DROP TABLE "products_taobao_links" CASCADE; + DROP TABLE "preorder_products_taobao_links" CASCADE; + DROP TABLE "disassembly_pages_components_linked_products" CASCADE; + DROP TABLE "disassembly_pages_components" CASCADE; + DROP TABLE "disassembly_pages" CASCADE; + DROP TABLE "disassembly_pages_rels" CASCADE; + DROP TABLE "hero_slider_rels" CASCADE; + DROP TABLE "site_access" CASCADE; + ALTER TABLE "products_rels" DROP CONSTRAINT "products_rels_preorder_products_fk"; + + ALTER TABLE "preorder_products_rels" DROP CONSTRAINT "preorder_products_rels_products_fk"; + + ALTER TABLE "payload_locked_documents_rels" DROP CONSTRAINT "payload_locked_documents_rels_disassembly_pages_fk"; + + DROP INDEX "products_handle_idx"; + DROP INDEX "products_seed_id_idx"; + DROP INDEX "products_rels_preorder_products_id_idx"; + DROP INDEX "preorder_products_handle_idx"; + DROP INDEX "preorder_products_seed_id_idx"; + DROP INDEX "preorder_products_rels_products_id_idx"; + DROP INDEX "payload_locked_documents_rels_disassembly_pages_id_idx"; + ALTER TABLE "preorder_products" ALTER COLUMN "description" SET DATA TYPE jsonb; + ALTER TABLE "hero_slider_slides" ALTER COLUMN "subtitle" DROP NOT NULL; + ALTER TABLE "preorder_products_rels" ADD COLUMN "order_products_id" integer; + ALTER TABLE "payload_locked_documents_rels" ADD COLUMN "order_products_id" integer; + ALTER TABLE "hero_slider_slides" ADD COLUMN "image_mobile_id" integer; + ALTER TABLE "product_recommendations_rels" ADD COLUMN "order_products_id" integer; + ALTER TABLE "order_products_rels" ADD CONSTRAINT "order_products_rels_parent_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."order_products"("id") ON DELETE cascade ON UPDATE no action; + ALTER TABLE "order_products_rels" ADD CONSTRAINT "order_products_rels_preorder_products_fk" FOREIGN KEY ("preorder_products_id") REFERENCES "public"."preorder_products"("id") ON DELETE cascade ON UPDATE no action; + ALTER TABLE "order_products_rels" ADD CONSTRAINT "order_products_rels_order_products_fk" FOREIGN KEY ("order_products_id") REFERENCES "public"."order_products"("id") ON DELETE cascade ON UPDATE no action; + CREATE UNIQUE INDEX "order_products_medusa_id_idx" ON "order_products" USING btree ("medusa_id"); + CREATE INDEX "order_products_updated_at_idx" ON "order_products" USING btree ("updated_at"); + CREATE INDEX "order_products_created_at_idx" ON "order_products" USING btree ("created_at"); + CREATE INDEX "order_products_rels_order_idx" ON "order_products_rels" USING btree ("order"); + CREATE INDEX "order_products_rels_parent_idx" ON "order_products_rels" USING btree ("parent_id"); + CREATE INDEX "order_products_rels_path_idx" ON "order_products_rels" USING btree ("path"); + CREATE INDEX "order_products_rels_preorder_products_id_idx" ON "order_products_rels" USING btree ("preorder_products_id"); + CREATE INDEX "order_products_rels_order_products_id_idx" ON "order_products_rels" USING btree ("order_products_id"); + ALTER TABLE "preorder_products_rels" ADD CONSTRAINT "preorder_products_rels_order_products_fk" FOREIGN KEY ("order_products_id") REFERENCES "public"."order_products"("id") ON DELETE cascade ON UPDATE no action; + ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_order_products_fk" FOREIGN KEY ("order_products_id") REFERENCES "public"."order_products"("id") ON DELETE cascade ON UPDATE no action; + ALTER TABLE "hero_slider_slides" ADD CONSTRAINT "hero_slider_slides_image_mobile_id_media_id_fk" FOREIGN KEY ("image_mobile_id") REFERENCES "public"."media"("id") ON DELETE set null ON UPDATE no action; + ALTER TABLE "product_recommendations_rels" ADD CONSTRAINT "product_recommendations_rels_order_products_fk" FOREIGN KEY ("order_products_id") REFERENCES "public"."order_products"("id") ON DELETE cascade ON UPDATE no action; + CREATE INDEX "preorder_products_rels_order_products_id_idx" ON "preorder_products_rels" USING btree ("order_products_id"); + CREATE INDEX "payload_locked_documents_rels_order_products_id_idx" ON "payload_locked_documents_rels" USING btree ("order_products_id"); + CREATE INDEX "hero_slider_slides_image_mobile_idx" ON "hero_slider_slides" USING btree ("image_mobile_id"); + CREATE INDEX "product_recommendations_rels_order_products_id_idx" ON "product_recommendations_rels" USING btree ("order_products_id"); + ALTER TABLE "products" DROP COLUMN "seed_id"; + ALTER TABLE "products" DROP COLUMN "start_price"; + ALTER TABLE "products" DROP COLUMN "description"; + ALTER TABLE "products" DROP COLUMN "tags"; + ALTER TABLE "products" DROP COLUMN "type"; + ALTER TABLE "products" DROP COLUMN "collection"; + ALTER TABLE "products" DROP COLUMN "category"; + ALTER TABLE "products" DROP COLUMN "height"; + ALTER TABLE "products" DROP COLUMN "width"; + ALTER TABLE "products" DROP COLUMN "length"; + ALTER TABLE "products" DROP COLUMN "weight"; + ALTER TABLE "products" DROP COLUMN "mid_code"; + ALTER TABLE "products" DROP COLUMN "hs_code"; + ALTER TABLE "products" DROP COLUMN "country_of_origin"; + ALTER TABLE "products_rels" DROP COLUMN "preorder_products_id"; + ALTER TABLE "preorder_products" DROP COLUMN "seed_id"; + ALTER TABLE "preorder_products" DROP COLUMN "start_price"; + ALTER TABLE "preorder_products" DROP COLUMN "preorder_type"; + ALTER TABLE "preorder_products" DROP COLUMN "funding_goal"; + ALTER TABLE "preorder_products" DROP COLUMN "preorder_start_date"; + ALTER TABLE "preorder_products" DROP COLUMN "preorder_end_date"; + ALTER TABLE "preorder_products" DROP COLUMN "order_count"; + ALTER TABLE "preorder_products" DROP COLUMN "fake_order_count"; + ALTER TABLE "preorder_products" DROP COLUMN "content"; + ALTER TABLE "preorder_products" DROP COLUMN "tags"; + ALTER TABLE "preorder_products" DROP COLUMN "type"; + ALTER TABLE "preorder_products" DROP COLUMN "collection"; + ALTER TABLE "preorder_products" DROP COLUMN "category"; + ALTER TABLE "preorder_products" DROP COLUMN "height"; + ALTER TABLE "preorder_products" DROP COLUMN "width"; + ALTER TABLE "preorder_products" DROP COLUMN "length"; + ALTER TABLE "preorder_products" DROP COLUMN "weight"; + ALTER TABLE "preorder_products" DROP COLUMN "mid_code"; + ALTER TABLE "preorder_products" DROP COLUMN "hs_code"; + ALTER TABLE "preorder_products" DROP COLUMN "country_of_origin"; + ALTER TABLE "preorder_products_rels" DROP COLUMN "products_id"; + ALTER TABLE "payload_locked_documents_rels" DROP COLUMN "disassembly_pages_id"; + ALTER TABLE "hero_slider_slides" DROP COLUMN "desc"; + ALTER TABLE "hero_slider_slides" DROP COLUMN "layout"; + ALTER TABLE "hero_slider_slides" DROP COLUMN "show_focus_circle"; + ALTER TABLE "hero_slider_slides" DROP COLUMN "price"; + ALTER TABLE "product_recommendations_lists" DROP COLUMN "preorder"; + DROP TYPE "public"."enum_preorder_products_preorder_type"; + DROP TYPE "public"."enum_hero_slider_slides_layout";`) +} diff --git a/src/migrations/20260223_disassembly_refactor.ts b/src/migrations/20260223_disassembly_refactor.ts new file mode 100644 index 0000000..d9acace --- /dev/null +++ b/src/migrations/20260223_disassembly_refactor.ts @@ -0,0 +1,250 @@ +import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres' + +/** + * 迁移:将 disassembly_pages 的嵌套数组表重构为三个独立 Collection + * + * 旧结构(arrays): + * disassembly_pages + * disassembly_pages_components (array: order, parent_id, label, 坐标, 半径) + * disassembly_pages_components_linked_products (nested array: order, parent_id, 坐标, product_name) + * disassembly_pages_rels (products_id, preorder_products_id) + * + * 新结构(独立 Collections): + * disassembly_pages (保留主表,rels 改为指向 disassembly_components) + * disassembly_components (第二层 Collection) + * disassembly_components_rels (linkedProducts → disassembly_linked_products) + * disassembly_linked_products (第三层 Collection) + * disassembly_linked_products_rels (products, preorder_products) + */ +export async function up({ db, payload, req }: MigrateUpArgs): Promise { + await db.execute(sql` + -- ── 1. 创建 disassembly_components 表 ────────────────────────────── + CREATE TABLE "disassembly_components" ( + "id" serial PRIMARY KEY NOT NULL, + "label" varchar NOT NULL, + "start_coordinate_x" numeric DEFAULT 0 NOT NULL, + "start_coordinate_y" numeric DEFAULT 0 NOT NULL, + "start_radius" numeric DEFAULT 20 NOT NULL, + "updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL, + "created_at" timestamp(3) with time zone DEFAULT now() NOT NULL + ); + + CREATE INDEX "disassembly_components_updated_at_idx" + ON "disassembly_components" USING btree ("updated_at"); + CREATE INDEX "disassembly_components_created_at_idx" + ON "disassembly_components" USING btree ("created_at"); + + -- ── 2. 创建 disassembly_components_rels 表 ────────────────────────── + CREATE TABLE "disassembly_components_rels" ( + "id" serial PRIMARY KEY NOT NULL, + "order" integer, + "parent_id" integer NOT NULL, + "path" varchar NOT NULL, + "disassembly_linked_products_id" integer + ); + + ALTER TABLE "disassembly_components_rels" + ADD CONSTRAINT "disassembly_components_rels_parent_fk" + FOREIGN KEY ("parent_id") REFERENCES "public"."disassembly_components"("id") + ON DELETE cascade ON UPDATE no action; + + CREATE INDEX "disassembly_components_rels_order_idx" + ON "disassembly_components_rels" USING btree ("order"); + CREATE INDEX "disassembly_components_rels_parent_idx" + ON "disassembly_components_rels" USING btree ("parent_id"); + CREATE INDEX "disassembly_components_rels_path_idx" + ON "disassembly_components_rels" USING btree ("path"); + + -- ── 3. 创建 disassembly_linked_products 表 ────────────────────────── + CREATE TABLE "disassembly_linked_products" ( + "id" serial PRIMARY KEY NOT NULL, + "coordinate_x" numeric DEFAULT 0 NOT NULL, + "coordinate_y" numeric DEFAULT 0 NOT NULL, + "product_name" varchar, + "updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL, + "created_at" timestamp(3) with time zone DEFAULT now() NOT NULL + ); + + CREATE INDEX "disassembly_linked_products_updated_at_idx" + ON "disassembly_linked_products" USING btree ("updated_at"); + CREATE INDEX "disassembly_linked_products_created_at_idx" + ON "disassembly_linked_products" USING btree ("created_at"); + + -- ── 4. 创建 disassembly_linked_products_rels 表 ───────────────────── + CREATE TABLE "disassembly_linked_products_rels" ( + "id" serial PRIMARY KEY NOT NULL, + "order" integer, + "parent_id" integer NOT NULL, + "path" varchar NOT NULL, + "products_id" integer, + "preorder_products_id" integer + ); + + ALTER TABLE "disassembly_linked_products_rels" + ADD CONSTRAINT "disassembly_linked_products_rels_parent_fk" + FOREIGN KEY ("parent_id") REFERENCES "public"."disassembly_linked_products"("id") + ON DELETE cascade ON UPDATE no action; + + ALTER TABLE "disassembly_linked_products_rels" + ADD CONSTRAINT "disassembly_linked_products_rels_products_fk" + FOREIGN KEY ("products_id") REFERENCES "public"."products"("id") + ON DELETE cascade ON UPDATE no action; + + ALTER TABLE "disassembly_linked_products_rels" + ADD CONSTRAINT "disassembly_linked_products_rels_preorder_products_fk" + FOREIGN KEY ("preorder_products_id") REFERENCES "public"."preorder_products"("id") + ON DELETE cascade ON UPDATE no action; + + CREATE INDEX "disassembly_linked_products_rels_order_idx" + ON "disassembly_linked_products_rels" USING btree ("order"); + CREATE INDEX "disassembly_linked_products_rels_parent_idx" + ON "disassembly_linked_products_rels" USING btree ("parent_id"); + CREATE INDEX "disassembly_linked_products_rels_path_idx" + ON "disassembly_linked_products_rels" USING btree ("path"); + CREATE INDEX "disassembly_linked_products_rels_products_id_idx" + ON "disassembly_linked_products_rels" USING btree ("products_id"); + CREATE INDEX "disassembly_linked_products_rels_preorder_products_id_idx" + ON "disassembly_linked_products_rels" USING btree ("preorder_products_id"); + + -- ── 5. 修改 disassembly_pages_rels:指向 disassembly_components ────── + -- 移除旧的 products/preorder_products 外键及列(已迁移到 disassembly_linked_products_rels) + ALTER TABLE "disassembly_pages_rels" + DROP CONSTRAINT IF EXISTS "disassembly_pages_rels_products_fk"; + ALTER TABLE "disassembly_pages_rels" + DROP CONSTRAINT IF EXISTS "disassembly_pages_rels_preorder_products_fk"; + DROP INDEX IF EXISTS "disassembly_pages_rels_products_id_idx"; + DROP INDEX IF EXISTS "disassembly_pages_rels_preorder_products_id_idx"; + ALTER TABLE "disassembly_pages_rels" DROP COLUMN IF EXISTS "products_id"; + ALTER TABLE "disassembly_pages_rels" DROP COLUMN IF EXISTS "preorder_products_id"; + + -- 添加 disassembly_components_id 列 + ALTER TABLE "disassembly_pages_rels" + ADD COLUMN "disassembly_components_id" integer; + + ALTER TABLE "disassembly_pages_rels" + ADD CONSTRAINT "disassembly_pages_rels_disassembly_components_fk" + FOREIGN KEY ("disassembly_components_id") REFERENCES "public"."disassembly_components"("id") + ON DELETE cascade ON UPDATE no action; + + CREATE INDEX "disassembly_pages_rels_disassembly_components_id_idx" + ON "disassembly_pages_rels" USING btree ("disassembly_components_id"); + + -- ── 6. 添加 payload_locked_documents_rels 的新 Collection 引用 ──────── + ALTER TABLE "payload_locked_documents_rels" + ADD COLUMN "disassembly_components_id" integer; + ALTER TABLE "payload_locked_documents_rels" + ADD COLUMN "disassembly_linked_products_id" integer; + + ALTER TABLE "payload_locked_documents_rels" + ADD CONSTRAINT "payload_locked_documents_rels_disassembly_components_fk" + FOREIGN KEY ("disassembly_components_id") REFERENCES "public"."disassembly_components"("id") + ON DELETE cascade ON UPDATE no action; + + ALTER TABLE "payload_locked_documents_rels" + ADD CONSTRAINT "payload_locked_documents_rels_disassembly_linked_products_fk" + FOREIGN KEY ("disassembly_linked_products_id") REFERENCES "public"."disassembly_linked_products"("id") + ON DELETE cascade ON UPDATE no action; + + CREATE INDEX "payload_locked_documents_rels_disassembly_components_id_idx" + ON "payload_locked_documents_rels" USING btree ("disassembly_components_id"); + CREATE INDEX "payload_locked_documents_rels_disassembly_linked_products_id_idx" + ON "payload_locked_documents_rels" USING btree ("disassembly_linked_products_id"); + + -- ── 7. 为 disassembly_components_rels 添加外键(在目标表创建后)──────── + ALTER TABLE "disassembly_components_rels" + ADD CONSTRAINT "disassembly_components_rels_disassembly_linked_products_fk" + FOREIGN KEY ("disassembly_linked_products_id") REFERENCES "public"."disassembly_linked_products"("id") + ON DELETE cascade ON UPDATE no action; + + CREATE INDEX "disassembly_components_rels_disassembly_linked_products_id_idx" + ON "disassembly_components_rels" USING btree ("disassembly_linked_products_id"); + + -- ── 8. 删除旧的嵌套数组表 ─────────────────────────────────────────── + ALTER TABLE "disassembly_pages_components_linked_products" DISABLE ROW LEVEL SECURITY; + ALTER TABLE "disassembly_pages_components" DISABLE ROW LEVEL SECURITY; + DROP TABLE "disassembly_pages_components_linked_products" CASCADE; + DROP TABLE "disassembly_pages_components" CASCADE; + `) +} + +export async function down({ db, payload, req }: MigrateDownArgs): Promise { + await db.execute(sql` + -- ── 还原:重新创建旧的嵌套数组表 ──────────────────────────────────── + CREATE TABLE "disassembly_pages_components_linked_products" ( + "_order" integer NOT NULL, + "_parent_id" varchar NOT NULL, + "id" varchar PRIMARY KEY NOT NULL, + "coordinate_x" numeric DEFAULT 0 NOT NULL, + "coordinate_y" numeric DEFAULT 0 NOT NULL, + "product_name" varchar + ); + + CREATE TABLE "disassembly_pages_components" ( + "_order" integer NOT NULL, + "_parent_id" integer NOT NULL, + "id" varchar PRIMARY KEY NOT NULL, + "label" varchar, + "start_coordinate_x" numeric DEFAULT 0 NOT NULL, + "start_coordinate_y" numeric DEFAULT 0 NOT NULL, + "start_radius" numeric DEFAULT 20 NOT NULL + ); + + ALTER TABLE "disassembly_pages_components_linked_products" + ADD CONSTRAINT "disassembly_pages_components_linked_products_parent_id_fk" + FOREIGN KEY ("_parent_id") REFERENCES "public"."disassembly_pages_components"("id") + ON DELETE cascade ON UPDATE no action; + + ALTER TABLE "disassembly_pages_components" + ADD CONSTRAINT "disassembly_pages_components_parent_id_fk" + FOREIGN KEY ("_parent_id") REFERENCES "public"."disassembly_pages"("id") + ON DELETE cascade ON UPDATE no action; + + CREATE INDEX "disassembly_pages_components_linked_products_order_idx" + ON "disassembly_pages_components_linked_products" USING btree ("_order"); + CREATE INDEX "disassembly_pages_components_linked_products_parent_id_idx" + ON "disassembly_pages_components_linked_products" USING btree ("_parent_id"); + CREATE INDEX "disassembly_pages_components_order_idx" + ON "disassembly_pages_components" USING btree ("_order"); + CREATE INDEX "disassembly_pages_components_parent_id_idx" + ON "disassembly_pages_components" USING btree ("_parent_id"); + + -- 还原 disassembly_pages_rels + ALTER TABLE "disassembly_pages_rels" + DROP CONSTRAINT IF EXISTS "disassembly_pages_rels_disassembly_components_fk"; + DROP INDEX IF EXISTS "disassembly_pages_rels_disassembly_components_id_idx"; + ALTER TABLE "disassembly_pages_rels" DROP COLUMN IF EXISTS "disassembly_components_id"; + + ALTER TABLE "disassembly_pages_rels" ADD COLUMN "products_id" integer; + ALTER TABLE "disassembly_pages_rels" ADD COLUMN "preorder_products_id" integer; + + ALTER TABLE "disassembly_pages_rels" + ADD CONSTRAINT "disassembly_pages_rels_products_fk" + FOREIGN KEY ("products_id") REFERENCES "public"."products"("id") + ON DELETE cascade ON UPDATE no action; + ALTER TABLE "disassembly_pages_rels" + ADD CONSTRAINT "disassembly_pages_rels_preorder_products_fk" + FOREIGN KEY ("preorder_products_id") REFERENCES "public"."preorder_products"("id") + ON DELETE cascade ON UPDATE no action; + + CREATE INDEX "disassembly_pages_rels_products_id_idx" + ON "disassembly_pages_rels" USING btree ("products_id"); + CREATE INDEX "disassembly_pages_rels_preorder_products_id_idx" + ON "disassembly_pages_rels" USING btree ("preorder_products_id"); + + -- 还原 payload_locked_documents_rels + ALTER TABLE "payload_locked_documents_rels" + DROP CONSTRAINT IF EXISTS "payload_locked_documents_rels_disassembly_components_fk"; + ALTER TABLE "payload_locked_documents_rels" + DROP CONSTRAINT IF EXISTS "payload_locked_documents_rels_disassembly_linked_products_fk"; + DROP INDEX IF EXISTS "payload_locked_documents_rels_disassembly_components_id_idx"; + DROP INDEX IF EXISTS "payload_locked_documents_rels_disassembly_linked_products_id_idx"; + ALTER TABLE "payload_locked_documents_rels" DROP COLUMN IF EXISTS "disassembly_components_id"; + ALTER TABLE "payload_locked_documents_rels" DROP COLUMN IF EXISTS "disassembly_linked_products_id"; + + -- 删除新的 Collection 表 + DROP TABLE IF EXISTS "disassembly_linked_products_rels" CASCADE; + DROP TABLE IF EXISTS "disassembly_linked_products" CASCADE; + DROP TABLE IF EXISTS "disassembly_components_rels" CASCADE; + DROP TABLE IF EXISTS "disassembly_components" CASCADE; + `) +} diff --git a/src/migrations/index.ts b/src/migrations/index.ts index 60e69e2..9a20a0c 100644 --- a/src/migrations/index.ts +++ b/src/migrations/index.ts @@ -1,8 +1,10 @@ -import * as migration_20260208_171142 from './20260208_171142' -import * as migration_20260212_193303 from './20260212_193303' -import * as migration_20260212_202303 from './20260212_202303' -import * as migration_hero_slider_simplify from './hero_slider_simplify' -import * as migration_product_recommendations_simplify from './product_recommendations_simplify' +import * as migration_20260208_171142 from './20260208_171142'; +import * as migration_20260212_193303 from './20260212_193303'; +import * as migration_20260212_202303 from './20260212_202303'; +import * as migration_20260222_170233 from './20260222_170233'; +import * as migration_hero_slider_simplify from './hero_slider_simplify'; +import * as migration_product_recommendations_simplify from './product_recommendations_simplify'; +import * as migration_20260223_disassembly_refactor from './20260223_disassembly_refactor'; export const migrations = [ { @@ -17,14 +19,27 @@ export const migrations = [ }, { up: migration_20260212_202303.up, + down: migration_20260212_202303.down, name: '20260212_202303', }, + { + up: migration_20260222_170233.up, + down: migration_20260222_170233.down, + name: '20260222_170233', + }, { up: migration_hero_slider_simplify.up, + down: migration_hero_slider_simplify.down, name: 'hero_slider_simplify', }, { up: migration_product_recommendations_simplify.up, - name: 'product_recommendations_simplify', + down: migration_product_recommendations_simplify.down, + name: 'product_recommendations_simplify' }, -] + { + up: migration_20260223_disassembly_refactor.up, + down: migration_20260223_disassembly_refactor.down, + name: '20260223_disassembly_refactor', + }, +]; diff --git a/src/payload-types.ts b/src/payload-types.ts index 590bb40..80e49d3 100644 --- a/src/payload-types.ts +++ b/src/payload-types.ts @@ -74,6 +74,9 @@ export interface Config { announcements: Announcement; articles: Article; logs: Log; + 'disassembly-pages': DisassemblyPage; + 'disassembly-components': DisassemblyComponent; + 'disassembly-linked-products': DisassemblyLinkedProduct; 'payload-kv': PayloadKv; 'payload-jobs': PayloadJob; 'payload-locked-documents': PayloadLockedDocument; @@ -89,6 +92,9 @@ export interface Config { announcements: AnnouncementsSelect | AnnouncementsSelect; articles: ArticlesSelect | ArticlesSelect; logs: LogsSelect | LogsSelect; + 'disassembly-pages': DisassemblyPagesSelect | DisassemblyPagesSelect; + 'disassembly-components': DisassemblyComponentsSelect | DisassemblyComponentsSelect; + 'disassembly-linked-products': DisassemblyLinkedProductsSelect | DisassemblyLinkedProductsSelect; 'payload-kv': PayloadKvSelect | PayloadKvSelect; 'payload-jobs': PayloadJobsSelect | PayloadJobsSelect; 'payload-locked-documents': PayloadLockedDocumentsSelect | PayloadLockedDocumentsSelect; @@ -697,6 +703,99 @@ export interface Log { updatedAt: string; createdAt: string; } +/** + * 管理产品拆解页,包含拆解组件和关联商品信息 + * + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "disassembly-pages". + */ +export interface DisassemblyPage { + id: number; + mainImage: number | Media; + name: string; + /** + * 该拆解页对应的页面路径或外部链接 + */ + url?: string | null; + /** + * 该拆解页包含的拆解组件列表 + */ + components?: (number | DisassemblyComponent)[] | null; + updatedAt: string; + createdAt: string; +} +/** + * 拆解页中的拆解组件(通过拆解页管理) + * + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "disassembly-components". + */ +export interface DisassemblyComponent { + id: number; + /** + * 用于 Admin 面板中标识该组件 + */ + label: string; + /** + * 组件锚点在页面/图片上的坐标 + */ + startCoordinate: { + /** + * 水平坐标 + */ + x: number; + /** + * 垂直坐标 + */ + y: number; + }; + /** + * 锚点热区半径(px) + */ + startRadius: number; + /** + * 该组件下的关联商品信息条目 + */ + linkedProducts?: (number | DisassemblyLinkedProduct)[] | null; + updatedAt: string; + createdAt: string; +} +/** + * 拆解组件中的关联商品信息(通过拆解组件管理) + * + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "disassembly-linked-products". + */ +export interface DisassemblyLinkedProduct { + id: number; + /** + * 商品标注在图片上的坐标 + */ + coordinate: { + /** + * 水平坐标 + */ + x: number; + /** + * 垂直坐标 + */ + y: number; + }; + /** + * 展示在标注上的商品名称,留空则使用关联商品标题 + */ + productName?: string | null; + /** + * 关联的普通商品 + */ + products?: (number | Product)[] | null; + /** + * 关联的预售商品 + */ + preorderProducts?: (number | PreorderProduct)[] | null; + updatedAt: string; + createdAt: string; +} /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "payload-kv". @@ -840,6 +939,18 @@ export interface PayloadLockedDocument { | ({ relationTo: 'logs'; value: number | Log; + } | null) + | ({ + relationTo: 'disassembly-pages'; + value: number | DisassemblyPage; + } | null) + | ({ + relationTo: 'disassembly-components'; + value: number | DisassemblyComponent; + } | null) + | ({ + relationTo: 'disassembly-linked-products'; + value: number | DisassemblyLinkedProduct; } | null); globalSlug?: string | null; user: { @@ -1067,6 +1178,52 @@ export interface LogsSelect { updatedAt?: T; createdAt?: T; } +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "disassembly-pages_select". + */ +export interface DisassemblyPagesSelect { + mainImage?: T; + name?: T; + url?: T; + components?: T; + updatedAt?: T; + createdAt?: T; +} +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "disassembly-components_select". + */ +export interface DisassemblyComponentsSelect { + label?: T; + startCoordinate?: + | T + | { + x?: T; + y?: T; + }; + startRadius?: T; + linkedProducts?: T; + updatedAt?: T; + createdAt?: T; +} +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "disassembly-linked-products_select". + */ +export interface DisassemblyLinkedProductsSelect { + coordinate?: + | T + | { + x?: T; + y?: T; + }; + productName?: T; + products?: T; + preorderProducts?: T; + updatedAt?: T; + createdAt?: T; +} /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "payload-kv_select". diff --git a/src/payload.config.ts b/src/payload.config.ts index c7dda05..4cb2d2a 100644 --- a/src/payload.config.ts +++ b/src/payload.config.ts @@ -12,6 +12,9 @@ import { PreorderProducts } from './collections/PreorderProducts' import { Announcements } from './collections/Announcements' import { Articles } from './collections/Articles' import { Logs } from './collections/Logs' +import { DisassemblyPages } from './collections/disassembly/DisassemblyPages' +import { DisassemblyComponents } from './collections/disassembly/DisassemblyComponents' +import { DisassemblyLinkedProducts } from './collections/disassembly/DisassemblyLinkedProducts' import { AdminSettings } from './globals/AdminSettings' import { LogsManager } from './globals/LogsManager' import { HeroSlider } from './globals/HeroSlider' @@ -48,7 +51,7 @@ export default buildConfig({ }, fallbackLanguage: 'zh', }, - collections: [Users, Media, Products, PreorderProducts, Announcements, Articles, Logs], + collections: [Users, Media, Products, PreorderProducts, Announcements, Articles, Logs, DisassemblyPages, DisassemblyComponents, DisassemblyLinkedProducts], globals: [AdminSettings, LogsManager, HeroSlider, ProductRecommendations, SiteAccess], editor: lexicalEditor(), secret: process.env.PAYLOAD_SECRET || '',