精简product
This commit is contained in:
parent
e9947bdbdd
commit
4fb29d9cb7
|
|
@ -0,0 +1,32 @@
|
||||||
|
import type { CollectionConfig } from 'payload'
|
||||||
|
import { logAfterChange, logAfterDelete } from '../hooks/logAction'
|
||||||
|
import { PrecautionItemFields } from './base/ProductBase'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用注意事项集合
|
||||||
|
* 与产品内嵌注意事项共用 PrecautionItemFields 结构(title / summary / order)
|
||||||
|
* Products / PreorderProducts 可通过 sharedPrecautions 关联字段引用
|
||||||
|
*/
|
||||||
|
export const Precautions: CollectionConfig = {
|
||||||
|
slug: 'precautions',
|
||||||
|
admin: {
|
||||||
|
useAsTitle: 'title',
|
||||||
|
defaultColumns: ['title', 'summary', 'updatedAt'],
|
||||||
|
description: '管理通用注意事项,可被多个产品复用引用',
|
||||||
|
pagination: {
|
||||||
|
defaultLimit: 25,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
access: {
|
||||||
|
read: () => true,
|
||||||
|
create: ({ req: { user } }) => !!user,
|
||||||
|
update: ({ req: { user } }) => !!user,
|
||||||
|
delete: ({ req: { user } }) => !!user,
|
||||||
|
},
|
||||||
|
fields: PrecautionItemFields,
|
||||||
|
hooks: {
|
||||||
|
afterChange: [logAfterChange],
|
||||||
|
afterDelete: [logAfterDelete],
|
||||||
|
},
|
||||||
|
timestamps: true,
|
||||||
|
}
|
||||||
|
|
@ -113,6 +113,14 @@ export const ProductBaseFields: Field[] = [
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'accessPassword',
|
||||||
|
type: 'text',
|
||||||
|
admin: {
|
||||||
|
description: '访问密码(用于保护特定产品页面或内容)',
|
||||||
|
placeholder: '留空则不限制访问',
|
||||||
|
},
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -286,3 +294,112 @@ export const RelatedProductsField: Field = {
|
||||||
|
|
||||||
// TaobaoLinksField 已移至独立文件,包含自动解析功能
|
// TaobaoLinksField 已移至独立文件,包含自动解析功能
|
||||||
export { TaobaoLinksField } from './TaobaoLinksField'
|
export { TaobaoLinksField } from './TaobaoLinksField'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目状态 Tab
|
||||||
|
* 内嵌数组,可在产品表单中直接添加和编辑,无需跳转新窗口
|
||||||
|
*/
|
||||||
|
export const ProjectStatusesTab: Tab = {
|
||||||
|
label: '📊 项目状态',
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
name: 'projectStatuses',
|
||||||
|
type: 'array',
|
||||||
|
admin: {
|
||||||
|
description: '产品项目状态列表,可直接在此添加和编辑',
|
||||||
|
},
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
name: 'title',
|
||||||
|
type: 'text',
|
||||||
|
required: true,
|
||||||
|
admin: {
|
||||||
|
description: '状态名称,例如:研发中、众筹中、量产中',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'badge',
|
||||||
|
type: 'text',
|
||||||
|
admin: {
|
||||||
|
description: '状态徽章标签(简短文字,展示在产品卡片上)',
|
||||||
|
placeholder: '例如: 研发中',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'description',
|
||||||
|
type: 'text',
|
||||||
|
admin: {
|
||||||
|
description: '状态简介',
|
||||||
|
placeholder: '请输入状态简介...',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'order',
|
||||||
|
type: 'number',
|
||||||
|
defaultValue: 0,
|
||||||
|
admin: {
|
||||||
|
description: '排序权重(数值越小越靠前)',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用注意事项条目字段结构
|
||||||
|
* 同时被 Precautions 集合和产品内嵌数组共用
|
||||||
|
*/
|
||||||
|
export const PrecautionItemFields: Field[] = [
|
||||||
|
{
|
||||||
|
name: 'title',
|
||||||
|
type: 'text',
|
||||||
|
required: true,
|
||||||
|
admin: {
|
||||||
|
description: '注意事项标题,例如:安装注意事项、使用须知',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'summary',
|
||||||
|
type: 'text',
|
||||||
|
admin: {
|
||||||
|
description: '注意事项摘要',
|
||||||
|
placeholder: '请输入注意事项摘要...',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'order',
|
||||||
|
type: 'number',
|
||||||
|
defaultValue: 0,
|
||||||
|
admin: {
|
||||||
|
description: '排序权重(数值越小越靠前)',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注意事项 Tab
|
||||||
|
* 内嵌数组,可在产品表单中直接添加和编辑,无需跳转新窗口
|
||||||
|
*/
|
||||||
|
export const PrecautionsTab: Tab = {
|
||||||
|
label: '⚠️ 注意事项',
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
name: 'sharedPrecautions',
|
||||||
|
type: 'relationship',
|
||||||
|
relationTo: 'precautions',
|
||||||
|
hasMany: true,
|
||||||
|
admin: {
|
||||||
|
description: '引用通用注意事项(在《通用注意事项》集合中统一管理,可被多个产品复用)',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'precautions',
|
||||||
|
type: 'array',
|
||||||
|
admin: {
|
||||||
|
description: '产品专属注意事项,可直接在此添加和编辑',
|
||||||
|
},
|
||||||
|
fields: PrecautionItemFields,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import type { CollectionConfig } from 'payload'
|
import type { CollectionConfig } from 'payload'
|
||||||
import { logAfterChange, logAfterDelete } from '../hooks/logAction'
|
import { logAfterChange, logAfterDelete } from '../../hooks/logAction'
|
||||||
import { cacheAfterChange, cacheAfterDelete } from '../hooks/cacheInvalidation'
|
import { cacheAfterChange, cacheAfterDelete } from '../../hooks/cacheInvalidation'
|
||||||
import { ProductBaseFields, RelatedProductsField, TaobaoLinksField, MedusaAttributesTab } from './base/ProductBase'
|
import { ProductBaseFields, RelatedProductsField, TaobaoLinksField, MedusaAttributesTab, ProjectStatusesTab, PrecautionsTab } from '../base/ProductBase'
|
||||||
import {
|
import {
|
||||||
AlignFeature,
|
AlignFeature,
|
||||||
BlocksFeature,
|
BlocksFeature,
|
||||||
|
|
@ -240,6 +240,8 @@ export const PreorderProducts: CollectionConfig = {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
MedusaAttributesTab,
|
MedusaAttributesTab,
|
||||||
|
ProjectStatusesTab,
|
||||||
|
PrecautionsTab,
|
||||||
{
|
{
|
||||||
label: '🛒 淘宝链接',
|
label: '🛒 淘宝链接',
|
||||||
fields: [
|
fields: [
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import type { CollectionConfig } from 'payload'
|
import type { CollectionConfig } from 'payload'
|
||||||
import { logAfterChange, logAfterDelete } from '../hooks/logAction'
|
import { logAfterChange, logAfterDelete } from '../../hooks/logAction'
|
||||||
import { cacheAfterChange, cacheAfterDelete } from '../hooks/cacheInvalidation'
|
import { cacheAfterChange, cacheAfterDelete } from '../../hooks/cacheInvalidation'
|
||||||
import { ProductBaseFields, RelatedProductsField, MedusaAttributesTab } from './base/ProductBase'
|
import { ProductBaseFields, RelatedProductsField, MedusaAttributesTab, ProjectStatusesTab, PrecautionsTab } from '../base/ProductBase'
|
||||||
import { TaobaoLinksField } from './base/TaobaoLinksField'
|
import { TaobaoLinksField } from '../base/TaobaoLinksField'
|
||||||
import {
|
import {
|
||||||
AlignFeature,
|
AlignFeature,
|
||||||
BlocksFeature,
|
BlocksFeature,
|
||||||
|
|
@ -118,6 +118,8 @@ export const Products: CollectionConfig = {
|
||||||
fields: [RelatedProductsField],
|
fields: [RelatedProductsField],
|
||||||
},
|
},
|
||||||
MedusaAttributesTab,
|
MedusaAttributesTab,
|
||||||
|
ProjectStatusesTab,
|
||||||
|
PrecautionsTab,
|
||||||
{
|
{
|
||||||
label: '🛒 淘宝链接',
|
label: '🛒 淘宝链接',
|
||||||
fields: [
|
fields: [
|
||||||
|
|
@ -0,0 +1,128 @@
|
||||||
|
import type { CollectionConfig } from 'payload'
|
||||||
|
import { logAfterChange, logAfterDelete } from '../../hooks/logAction'
|
||||||
|
import {
|
||||||
|
BoldFeature,
|
||||||
|
HeadingFeature,
|
||||||
|
ItalicFeature,
|
||||||
|
lexicalEditor,
|
||||||
|
LinkFeature,
|
||||||
|
OrderedListFeature,
|
||||||
|
ParagraphFeature,
|
||||||
|
UnorderedListFeature,
|
||||||
|
FixedToolbarFeature,
|
||||||
|
InlineToolbarFeature,
|
||||||
|
HorizontalRuleFeature,
|
||||||
|
} from '@payloadcms/richtext-lexical'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注意事项集合
|
||||||
|
* 用于描述产品使用、购买、安装等过程中需要注意的事项
|
||||||
|
* 可被 Products 和 PreorderProducts 关联引用
|
||||||
|
*/
|
||||||
|
export const Precautions: CollectionConfig = {
|
||||||
|
slug: 'precautions',
|
||||||
|
admin: {
|
||||||
|
useAsTitle: 'title',
|
||||||
|
defaultColumns: ['title', 'type', 'updatedAt'],
|
||||||
|
description: '管理产品注意事项,如使用须知、安装注意、购买说明等',
|
||||||
|
pagination: {
|
||||||
|
defaultLimit: 25,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
access: {
|
||||||
|
read: () => true,
|
||||||
|
create: ({ req: { user } }) => !!user,
|
||||||
|
update: ({ req: { user } }) => !!user,
|
||||||
|
delete: ({ req: { user } }) => !!user,
|
||||||
|
},
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
type: 'tabs',
|
||||||
|
tabs: [
|
||||||
|
{
|
||||||
|
label: 'ℹ️ 基本信息',
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
type: 'row',
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
name: 'title',
|
||||||
|
type: 'text',
|
||||||
|
required: true,
|
||||||
|
admin: {
|
||||||
|
description: '注意事项标题,例如:安装注意事项、使用须知',
|
||||||
|
width: '60%',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'type',
|
||||||
|
type: 'select',
|
||||||
|
defaultValue: 'general',
|
||||||
|
admin: {
|
||||||
|
description: '注意事项类型',
|
||||||
|
width: '40%',
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
{ label: '通用', value: 'general' },
|
||||||
|
{ label: '安装', value: 'installation' },
|
||||||
|
{ label: '使用', value: 'usage' },
|
||||||
|
{ label: '购买', value: 'purchase' },
|
||||||
|
{ label: '售后', value: 'aftersale' },
|
||||||
|
{ label: '安全', value: 'safety' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'summary',
|
||||||
|
type: 'text',
|
||||||
|
admin: {
|
||||||
|
description: '注意事项摘要(纯文本,用于列表展示)',
|
||||||
|
placeholder: '请输入注意事项摘要...',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'order',
|
||||||
|
type: 'number',
|
||||||
|
defaultValue: 0,
|
||||||
|
admin: {
|
||||||
|
description: '排序权重(数值越小越靠前)',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '📄 详细内容',
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
name: 'content',
|
||||||
|
type: 'richText',
|
||||||
|
editor: lexicalEditor({
|
||||||
|
features: [
|
||||||
|
ParagraphFeature(),
|
||||||
|
HeadingFeature({ enabledHeadingSizes: ['h2', 'h3', 'h4'] }),
|
||||||
|
BoldFeature(),
|
||||||
|
ItalicFeature(),
|
||||||
|
UnorderedListFeature(),
|
||||||
|
OrderedListFeature(),
|
||||||
|
LinkFeature(),
|
||||||
|
HorizontalRuleFeature(),
|
||||||
|
FixedToolbarFeature(),
|
||||||
|
InlineToolbarFeature(),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
admin: {
|
||||||
|
description: '注意事项详细内容(富文本)',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
hooks: {
|
||||||
|
afterChange: [logAfterChange],
|
||||||
|
afterDelete: [logAfterDelete],
|
||||||
|
},
|
||||||
|
timestamps: true,
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,139 @@
|
||||||
|
import type { CollectionConfig } from 'payload'
|
||||||
|
import { logAfterChange, logAfterDelete } from '../../hooks/logAction'
|
||||||
|
import {
|
||||||
|
BoldFeature,
|
||||||
|
HeadingFeature,
|
||||||
|
ItalicFeature,
|
||||||
|
lexicalEditor,
|
||||||
|
LinkFeature,
|
||||||
|
OrderedListFeature,
|
||||||
|
ParagraphFeature,
|
||||||
|
UnorderedListFeature,
|
||||||
|
FixedToolbarFeature,
|
||||||
|
InlineToolbarFeature,
|
||||||
|
HorizontalRuleFeature,
|
||||||
|
} from '@payloadcms/richtext-lexical'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目状态集合
|
||||||
|
* 用于描述产品的项目进度、研发阶段等状态信息
|
||||||
|
* 可被 Products 和 PreorderProducts 关联引用
|
||||||
|
*/
|
||||||
|
export const ProjectStatuses: CollectionConfig = {
|
||||||
|
slug: 'project-statuses',
|
||||||
|
admin: {
|
||||||
|
hidden: true,
|
||||||
|
useAsTitle: 'title',
|
||||||
|
defaultColumns: ['title', 'badge', 'color', 'updatedAt'],
|
||||||
|
description: '管理产品项目状态,如研发中、量产中、已停产等',
|
||||||
|
pagination: {
|
||||||
|
defaultLimit: 25,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
access: {
|
||||||
|
read: () => true,
|
||||||
|
create: ({ req: { user } }) => !!user,
|
||||||
|
update: ({ req: { user } }) => !!user,
|
||||||
|
delete: ({ req: { user } }) => !!user,
|
||||||
|
},
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
type: 'tabs',
|
||||||
|
tabs: [
|
||||||
|
{
|
||||||
|
label: 'ℹ️ 基本信息',
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
type: 'row',
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
name: 'title',
|
||||||
|
type: 'text',
|
||||||
|
required: true,
|
||||||
|
admin: {
|
||||||
|
description: '状态名称,例如:研发中、众筹中、量产中',
|
||||||
|
width: '50%',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'badge',
|
||||||
|
type: 'text',
|
||||||
|
admin: {
|
||||||
|
description: '状态徽章标签(简短文字,展示在产品卡片上)',
|
||||||
|
placeholder: '例如: 研发中',
|
||||||
|
width: '25%',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'color',
|
||||||
|
type: 'select',
|
||||||
|
defaultValue: 'gray',
|
||||||
|
admin: {
|
||||||
|
description: '徽章颜色',
|
||||||
|
width: '25%',
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
{ label: '灰色', value: 'gray' },
|
||||||
|
{ label: '蓝色', value: 'blue' },
|
||||||
|
{ label: '绿色', value: 'green' },
|
||||||
|
{ label: '黄色', value: 'yellow' },
|
||||||
|
{ label: '橙色', value: 'orange' },
|
||||||
|
{ label: '红色', value: 'red' },
|
||||||
|
{ label: '紫色', value: 'purple' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'description',
|
||||||
|
type: 'text',
|
||||||
|
admin: {
|
||||||
|
description: '状态简介(纯文本,用于列表展示)',
|
||||||
|
placeholder: '请输入状态简介...',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'order',
|
||||||
|
type: 'number',
|
||||||
|
defaultValue: 0,
|
||||||
|
admin: {
|
||||||
|
description: '排序权重(数值越小越靠前)',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '📄 详细说明',
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
name: 'content',
|
||||||
|
type: 'richText',
|
||||||
|
editor: lexicalEditor({
|
||||||
|
features: [
|
||||||
|
ParagraphFeature(),
|
||||||
|
HeadingFeature({ enabledHeadingSizes: ['h2', 'h3', 'h4'] }),
|
||||||
|
BoldFeature(),
|
||||||
|
ItalicFeature(),
|
||||||
|
UnorderedListFeature(),
|
||||||
|
OrderedListFeature(),
|
||||||
|
LinkFeature(),
|
||||||
|
HorizontalRuleFeature(),
|
||||||
|
FixedToolbarFeature(),
|
||||||
|
InlineToolbarFeature(),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
admin: {
|
||||||
|
description: '状态详细说明(富文本,可包含进度描述、注意事项等)',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
hooks: {
|
||||||
|
afterChange: [logAfterChange],
|
||||||
|
afterDelete: [logAfterDelete],
|
||||||
|
},
|
||||||
|
timestamps: true,
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,169 +0,0 @@
|
||||||
import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'
|
|
||||||
|
|
||||||
export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
|
|
||||||
await db.execute(sql`
|
|
||||||
CREATE TYPE "public"."enum_products_status" AS ENUM('draft', 'published');
|
|
||||||
CREATE TABLE "users_sessions" (
|
|
||||||
"_order" integer NOT NULL,
|
|
||||||
"_parent_id" integer NOT NULL,
|
|
||||||
"id" varchar PRIMARY KEY NOT NULL,
|
|
||||||
"created_at" timestamp(3) with time zone,
|
|
||||||
"expires_at" timestamp(3) with time zone NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE "users" (
|
|
||||||
"id" serial PRIMARY KEY NOT NULL,
|
|
||||||
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
|
||||||
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
|
||||||
"email" varchar NOT NULL,
|
|
||||||
"reset_password_token" varchar,
|
|
||||||
"reset_password_expiration" timestamp(3) with time zone,
|
|
||||||
"salt" varchar,
|
|
||||||
"hash" varchar,
|
|
||||||
"login_attempts" numeric DEFAULT 0,
|
|
||||||
"lock_until" timestamp(3) with time zone
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE "media" (
|
|
||||||
"id" serial PRIMARY KEY NOT NULL,
|
|
||||||
"alt" varchar NOT NULL,
|
|
||||||
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
|
||||||
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
|
||||||
"url" varchar,
|
|
||||||
"thumbnail_u_r_l" varchar,
|
|
||||||
"filename" varchar,
|
|
||||||
"mime_type" varchar,
|
|
||||||
"filesize" numeric,
|
|
||||||
"width" numeric,
|
|
||||||
"height" numeric,
|
|
||||||
"focal_x" numeric,
|
|
||||||
"focal_y" numeric
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE "products" (
|
|
||||||
"id" serial PRIMARY KEY NOT NULL,
|
|
||||||
"medusa_id" varchar NOT NULL,
|
|
||||||
"title" varchar NOT NULL,
|
|
||||||
"handle" varchar,
|
|
||||||
"thumbnail" varchar,
|
|
||||||
"status" "enum_products_status" DEFAULT 'draft' NOT NULL,
|
|
||||||
"last_synced_at" timestamp(3) with time zone,
|
|
||||||
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
|
||||||
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE "products_rels" (
|
|
||||||
"id" serial PRIMARY KEY NOT NULL,
|
|
||||||
"order" integer,
|
|
||||||
"parent_id" integer NOT NULL,
|
|
||||||
"path" varchar NOT NULL,
|
|
||||||
"products_id" integer
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE "payload_kv" (
|
|
||||||
"id" serial PRIMARY KEY NOT NULL,
|
|
||||||
"key" varchar NOT NULL,
|
|
||||||
"data" jsonb NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE "payload_locked_documents" (
|
|
||||||
"id" serial PRIMARY KEY NOT NULL,
|
|
||||||
"global_slug" 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 "payload_locked_documents_rels" (
|
|
||||||
"id" serial PRIMARY KEY NOT NULL,
|
|
||||||
"order" integer,
|
|
||||||
"parent_id" integer NOT NULL,
|
|
||||||
"path" varchar NOT NULL,
|
|
||||||
"users_id" integer,
|
|
||||||
"media_id" integer,
|
|
||||||
"products_id" integer
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE "payload_preferences" (
|
|
||||||
"id" serial PRIMARY KEY NOT NULL,
|
|
||||||
"key" varchar,
|
|
||||||
"value" 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 "payload_preferences_rels" (
|
|
||||||
"id" serial PRIMARY KEY NOT NULL,
|
|
||||||
"order" integer,
|
|
||||||
"parent_id" integer NOT NULL,
|
|
||||||
"path" varchar NOT NULL,
|
|
||||||
"users_id" integer
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE "payload_migrations" (
|
|
||||||
"id" serial PRIMARY KEY NOT NULL,
|
|
||||||
"name" varchar,
|
|
||||||
"batch" numeric,
|
|
||||||
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
|
||||||
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
ALTER TABLE "users_sessions" ADD CONSTRAINT "users_sessions_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;
|
|
||||||
ALTER TABLE "products_rels" ADD CONSTRAINT "products_rels_parent_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."products"("id") ON DELETE cascade ON UPDATE no action;
|
|
||||||
ALTER TABLE "products_rels" ADD CONSTRAINT "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_parent_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."payload_locked_documents"("id") ON DELETE cascade ON UPDATE no action;
|
|
||||||
ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_users_fk" FOREIGN KEY ("users_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;
|
|
||||||
ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_media_fk" FOREIGN KEY ("media_id") REFERENCES "public"."media"("id") ON DELETE cascade ON UPDATE no action;
|
|
||||||
ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_products_fk" FOREIGN KEY ("products_id") REFERENCES "public"."products"("id") ON DELETE cascade ON UPDATE no action;
|
|
||||||
ALTER TABLE "payload_preferences_rels" ADD CONSTRAINT "payload_preferences_rels_parent_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."payload_preferences"("id") ON DELETE cascade ON UPDATE no action;
|
|
||||||
ALTER TABLE "payload_preferences_rels" ADD CONSTRAINT "payload_preferences_rels_users_fk" FOREIGN KEY ("users_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;
|
|
||||||
CREATE INDEX "users_sessions_order_idx" ON "users_sessions" USING btree ("_order");
|
|
||||||
CREATE INDEX "users_sessions_parent_id_idx" ON "users_sessions" USING btree ("_parent_id");
|
|
||||||
CREATE INDEX "users_updated_at_idx" ON "users" USING btree ("updated_at");
|
|
||||||
CREATE INDEX "users_created_at_idx" ON "users" USING btree ("created_at");
|
|
||||||
CREATE UNIQUE INDEX "users_email_idx" ON "users" USING btree ("email");
|
|
||||||
CREATE INDEX "media_updated_at_idx" ON "media" USING btree ("updated_at");
|
|
||||||
CREATE INDEX "media_created_at_idx" ON "media" USING btree ("created_at");
|
|
||||||
CREATE UNIQUE INDEX "media_filename_idx" ON "media" USING btree ("filename");
|
|
||||||
CREATE UNIQUE INDEX "products_medusa_id_idx" ON "products" USING btree ("medusa_id");
|
|
||||||
CREATE INDEX "products_updated_at_idx" ON "products" USING btree ("updated_at");
|
|
||||||
CREATE INDEX "products_created_at_idx" ON "products" USING btree ("created_at");
|
|
||||||
CREATE INDEX "products_rels_order_idx" ON "products_rels" USING btree ("order");
|
|
||||||
CREATE INDEX "products_rels_parent_idx" ON "products_rels" USING btree ("parent_id");
|
|
||||||
CREATE INDEX "products_rels_path_idx" ON "products_rels" USING btree ("path");
|
|
||||||
CREATE INDEX "products_rels_products_id_idx" ON "products_rels" USING btree ("products_id");
|
|
||||||
CREATE UNIQUE INDEX "payload_kv_key_idx" ON "payload_kv" USING btree ("key");
|
|
||||||
CREATE INDEX "payload_locked_documents_global_slug_idx" ON "payload_locked_documents" USING btree ("global_slug");
|
|
||||||
CREATE INDEX "payload_locked_documents_updated_at_idx" ON "payload_locked_documents" USING btree ("updated_at");
|
|
||||||
CREATE INDEX "payload_locked_documents_created_at_idx" ON "payload_locked_documents" USING btree ("created_at");
|
|
||||||
CREATE INDEX "payload_locked_documents_rels_order_idx" ON "payload_locked_documents_rels" USING btree ("order");
|
|
||||||
CREATE INDEX "payload_locked_documents_rels_parent_idx" ON "payload_locked_documents_rels" USING btree ("parent_id");
|
|
||||||
CREATE INDEX "payload_locked_documents_rels_path_idx" ON "payload_locked_documents_rels" USING btree ("path");
|
|
||||||
CREATE INDEX "payload_locked_documents_rels_users_id_idx" ON "payload_locked_documents_rels" USING btree ("users_id");
|
|
||||||
CREATE INDEX "payload_locked_documents_rels_media_id_idx" ON "payload_locked_documents_rels" USING btree ("media_id");
|
|
||||||
CREATE INDEX "payload_locked_documents_rels_products_id_idx" ON "payload_locked_documents_rels" USING btree ("products_id");
|
|
||||||
CREATE INDEX "payload_preferences_key_idx" ON "payload_preferences" USING btree ("key");
|
|
||||||
CREATE INDEX "payload_preferences_updated_at_idx" ON "payload_preferences" USING btree ("updated_at");
|
|
||||||
CREATE INDEX "payload_preferences_created_at_idx" ON "payload_preferences" USING btree ("created_at");
|
|
||||||
CREATE INDEX "payload_preferences_rels_order_idx" ON "payload_preferences_rels" USING btree ("order");
|
|
||||||
CREATE INDEX "payload_preferences_rels_parent_idx" ON "payload_preferences_rels" USING btree ("parent_id");
|
|
||||||
CREATE INDEX "payload_preferences_rels_path_idx" ON "payload_preferences_rels" USING btree ("path");
|
|
||||||
CREATE INDEX "payload_preferences_rels_users_id_idx" ON "payload_preferences_rels" USING btree ("users_id");
|
|
||||||
CREATE INDEX "payload_migrations_updated_at_idx" ON "payload_migrations" USING btree ("updated_at");
|
|
||||||
CREATE INDEX "payload_migrations_created_at_idx" ON "payload_migrations" USING btree ("created_at");`)
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
|
|
||||||
await db.execute(sql`
|
|
||||||
DROP TABLE "users_sessions" CASCADE;
|
|
||||||
DROP TABLE "users" CASCADE;
|
|
||||||
DROP TABLE "media" CASCADE;
|
|
||||||
DROP TABLE "products" CASCADE;
|
|
||||||
DROP TABLE "products_rels" CASCADE;
|
|
||||||
DROP TABLE "payload_kv" CASCADE;
|
|
||||||
DROP TABLE "payload_locked_documents" CASCADE;
|
|
||||||
DROP TABLE "payload_locked_documents_rels" CASCADE;
|
|
||||||
DROP TABLE "payload_preferences" CASCADE;
|
|
||||||
DROP TABLE "payload_preferences_rels" CASCADE;
|
|
||||||
DROP TABLE "payload_migrations" CASCADE;
|
|
||||||
DROP TYPE "public"."enum_products_status";`)
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,370 +0,0 @@
|
||||||
import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'
|
|
||||||
|
|
||||||
export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
|
|
||||||
await db.execute(sql`
|
|
||||||
CREATE TYPE "public"."enum_users_roles" AS ENUM('admin', 'editor', 'user');
|
|
||||||
CREATE TYPE "public"."enum_announcements_type" AS ENUM('info', 'warning', 'important', 'urgent');
|
|
||||||
CREATE TYPE "public"."enum_announcements_status" AS ENUM('draft', 'published', 'archived');
|
|
||||||
CREATE TYPE "public"."enum_articles_status" AS ENUM('draft', 'published');
|
|
||||||
CREATE TYPE "public"."enum_articles_category" AS ENUM('news', 'tutorial', 'tech', 'review', 'industry', 'other');
|
|
||||||
CREATE TYPE "public"."enum__articles_v_version_status" AS ENUM('draft', 'published');
|
|
||||||
CREATE TYPE "public"."enum__articles_v_version_category" AS ENUM('news', 'tutorial', 'tech', 'review', 'industry', 'other');
|
|
||||||
CREATE TYPE "public"."enum_logs_action" AS ENUM('create', 'update', 'delete', 'sync', 'login', 'logout');
|
|
||||||
CREATE TYPE "public"."enum_payload_jobs_log_task_slug" AS ENUM('inline', 'schedulePublish');
|
|
||||||
CREATE TYPE "public"."enum_payload_jobs_log_state" AS ENUM('failed', 'succeeded');
|
|
||||||
CREATE TYPE "public"."enum_payload_jobs_task_slug" AS ENUM('inline', 'schedulePublish');
|
|
||||||
CREATE TABLE "users_roles" (
|
|
||||||
"order" integer NOT NULL,
|
|
||||||
"parent_id" integer NOT NULL,
|
|
||||||
"value" "enum_users_roles",
|
|
||||||
"id" serial PRIMARY KEY NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE "announcements" (
|
|
||||||
"id" serial PRIMARY KEY NOT NULL,
|
|
||||||
"title" varchar NOT NULL,
|
|
||||||
"type" "enum_announcements_type" DEFAULT 'info' NOT NULL,
|
|
||||||
"status" "enum_announcements_status" DEFAULT 'draft' NOT NULL,
|
|
||||||
"priority" numeric DEFAULT 0,
|
|
||||||
"summary" varchar,
|
|
||||||
"content" jsonb NOT NULL,
|
|
||||||
"published_at" timestamp(3) with time zone,
|
|
||||||
"expires_at" timestamp(3) with time zone,
|
|
||||||
"show_on_homepage" boolean DEFAULT false,
|
|
||||||
"author_id" integer,
|
|
||||||
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
|
||||||
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE "articles" (
|
|
||||||
"id" serial PRIMARY KEY NOT NULL,
|
|
||||||
"title" varchar,
|
|
||||||
"status" "enum_articles_status" DEFAULT 'draft',
|
|
||||||
"slug" varchar,
|
|
||||||
"featured_image_id" integer,
|
|
||||||
"excerpt" varchar,
|
|
||||||
"content" jsonb,
|
|
||||||
"category" "enum_articles_category",
|
|
||||||
"featured" boolean DEFAULT false,
|
|
||||||
"author_id" integer,
|
|
||||||
"published_at" timestamp(3) with time zone,
|
|
||||||
"meta_title" varchar,
|
|
||||||
"meta_description" varchar,
|
|
||||||
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
|
||||||
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
|
||||||
"_status" "enum_articles_status" DEFAULT 'draft'
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE "articles_texts" (
|
|
||||||
"id" serial PRIMARY KEY NOT NULL,
|
|
||||||
"order" integer NOT NULL,
|
|
||||||
"parent_id" integer NOT NULL,
|
|
||||||
"path" varchar NOT NULL,
|
|
||||||
"text" varchar
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE "articles_rels" (
|
|
||||||
"id" serial PRIMARY KEY NOT NULL,
|
|
||||||
"order" integer,
|
|
||||||
"parent_id" integer NOT NULL,
|
|
||||||
"path" varchar NOT NULL,
|
|
||||||
"articles_id" integer,
|
|
||||||
"products_id" integer
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE "_articles_v" (
|
|
||||||
"id" serial PRIMARY KEY NOT NULL,
|
|
||||||
"parent_id" integer,
|
|
||||||
"version_title" varchar,
|
|
||||||
"version_status" "enum__articles_v_version_status" DEFAULT 'draft',
|
|
||||||
"version_slug" varchar,
|
|
||||||
"version_featured_image_id" integer,
|
|
||||||
"version_excerpt" varchar,
|
|
||||||
"version_content" jsonb,
|
|
||||||
"version_category" "enum__articles_v_version_category",
|
|
||||||
"version_featured" boolean DEFAULT false,
|
|
||||||
"version_author_id" integer,
|
|
||||||
"version_published_at" timestamp(3) with time zone,
|
|
||||||
"version_meta_title" varchar,
|
|
||||||
"version_meta_description" varchar,
|
|
||||||
"version_updated_at" timestamp(3) with time zone,
|
|
||||||
"version_created_at" timestamp(3) with time zone,
|
|
||||||
"version__status" "enum__articles_v_version_status" DEFAULT 'draft',
|
|
||||||
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
|
||||||
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
|
||||||
"latest" boolean,
|
|
||||||
"autosave" boolean
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE "_articles_v_texts" (
|
|
||||||
"id" serial PRIMARY KEY NOT NULL,
|
|
||||||
"order" integer NOT NULL,
|
|
||||||
"parent_id" integer NOT NULL,
|
|
||||||
"path" varchar NOT NULL,
|
|
||||||
"text" varchar
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE "_articles_v_rels" (
|
|
||||||
"id" serial PRIMARY KEY NOT NULL,
|
|
||||||
"order" integer,
|
|
||||||
"parent_id" integer NOT NULL,
|
|
||||||
"path" varchar NOT NULL,
|
|
||||||
"articles_id" integer,
|
|
||||||
"products_id" integer
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE "logs" (
|
|
||||||
"id" serial PRIMARY KEY NOT NULL,
|
|
||||||
"action" "enum_logs_action" NOT NULL,
|
|
||||||
"collection" varchar NOT NULL,
|
|
||||||
"document_id" varchar,
|
|
||||||
"document_title" varchar,
|
|
||||||
"user_id" integer NOT NULL,
|
|
||||||
"changes" jsonb,
|
|
||||||
"ip" varchar,
|
|
||||||
"user_agent" 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 "payload_jobs_log" (
|
|
||||||
"_order" integer NOT NULL,
|
|
||||||
"_parent_id" integer NOT NULL,
|
|
||||||
"id" varchar PRIMARY KEY NOT NULL,
|
|
||||||
"executed_at" timestamp(3) with time zone NOT NULL,
|
|
||||||
"completed_at" timestamp(3) with time zone NOT NULL,
|
|
||||||
"task_slug" "enum_payload_jobs_log_task_slug" NOT NULL,
|
|
||||||
"task_i_d" varchar NOT NULL,
|
|
||||||
"input" jsonb,
|
|
||||||
"output" jsonb,
|
|
||||||
"state" "enum_payload_jobs_log_state" NOT NULL,
|
|
||||||
"error" jsonb
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE "payload_jobs" (
|
|
||||||
"id" serial PRIMARY KEY NOT NULL,
|
|
||||||
"input" jsonb,
|
|
||||||
"completed_at" timestamp(3) with time zone,
|
|
||||||
"total_tried" numeric DEFAULT 0,
|
|
||||||
"has_error" boolean DEFAULT false,
|
|
||||||
"error" jsonb,
|
|
||||||
"task_slug" "enum_payload_jobs_task_slug",
|
|
||||||
"queue" varchar DEFAULT 'default',
|
|
||||||
"wait_until" timestamp(3) with time zone,
|
|
||||||
"processing" boolean DEFAULT false,
|
|
||||||
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
|
||||||
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE "admin_settings" (
|
|
||||||
"id" serial PRIMARY KEY NOT NULL,
|
|
||||||
"title" varchar DEFAULT '管理员设置',
|
|
||||||
"updated_at" timestamp(3) with time zone,
|
|
||||||
"created_at" timestamp(3) with time zone
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE "logs_manager" (
|
|
||||||
"id" serial PRIMARY KEY NOT NULL,
|
|
||||||
"placeholder" varchar,
|
|
||||||
"updated_at" timestamp(3) with time zone,
|
|
||||||
"created_at" timestamp(3) with time zone
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE "hero_slider_slides" (
|
|
||||||
"_order" integer NOT NULL,
|
|
||||||
"_parent_id" integer NOT NULL,
|
|
||||||
"id" varchar PRIMARY KEY NOT NULL,
|
|
||||||
"title" varchar NOT NULL,
|
|
||||||
"subtitle" varchar,
|
|
||||||
"image_id" integer NOT NULL,
|
|
||||||
"image_mobile_id" integer,
|
|
||||||
"link" varchar
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE "hero_slider" (
|
|
||||||
"id" serial PRIMARY KEY NOT NULL,
|
|
||||||
"updated_at" timestamp(3) with time zone,
|
|
||||||
"created_at" timestamp(3) with time zone
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE "product_recommendations_lists" (
|
|
||||||
"_order" integer NOT NULL,
|
|
||||||
"_parent_id" integer NOT NULL,
|
|
||||||
"id" varchar PRIMARY KEY NOT NULL,
|
|
||||||
"title" varchar NOT NULL,
|
|
||||||
"subtitle" varchar
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE "product_recommendations" (
|
|
||||||
"id" serial PRIMARY KEY NOT NULL,
|
|
||||||
"enabled" boolean DEFAULT true,
|
|
||||||
"updated_at" timestamp(3) with time zone,
|
|
||||||
"created_at" timestamp(3) with time zone
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE "product_recommendations_rels" (
|
|
||||||
"id" serial PRIMARY KEY NOT NULL,
|
|
||||||
"order" integer,
|
|
||||||
"parent_id" integer NOT NULL,
|
|
||||||
"path" varchar NOT NULL,
|
|
||||||
"products_id" integer
|
|
||||||
);
|
|
||||||
|
|
||||||
ALTER TABLE "products" ADD COLUMN "content" jsonb;
|
|
||||||
ALTER TABLE "payload_locked_documents_rels" ADD COLUMN "announcements_id" integer;
|
|
||||||
ALTER TABLE "payload_locked_documents_rels" ADD COLUMN "articles_id" integer;
|
|
||||||
ALTER TABLE "payload_locked_documents_rels" ADD COLUMN "logs_id" integer;
|
|
||||||
ALTER TABLE "users_roles" ADD CONSTRAINT "users_roles_parent_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;
|
|
||||||
ALTER TABLE "announcements" ADD CONSTRAINT "announcements_author_id_users_id_fk" FOREIGN KEY ("author_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;
|
|
||||||
ALTER TABLE "articles" ADD CONSTRAINT "articles_featured_image_id_media_id_fk" FOREIGN KEY ("featured_image_id") REFERENCES "public"."media"("id") ON DELETE set null ON UPDATE no action;
|
|
||||||
ALTER TABLE "articles" ADD CONSTRAINT "articles_author_id_users_id_fk" FOREIGN KEY ("author_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;
|
|
||||||
ALTER TABLE "articles_texts" ADD CONSTRAINT "articles_texts_parent_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."articles"("id") ON DELETE cascade ON UPDATE no action;
|
|
||||||
ALTER TABLE "articles_rels" ADD CONSTRAINT "articles_rels_parent_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."articles"("id") ON DELETE cascade ON UPDATE no action;
|
|
||||||
ALTER TABLE "articles_rels" ADD CONSTRAINT "articles_rels_articles_fk" FOREIGN KEY ("articles_id") REFERENCES "public"."articles"("id") ON DELETE cascade ON UPDATE no action;
|
|
||||||
ALTER TABLE "articles_rels" ADD CONSTRAINT "articles_rels_products_fk" FOREIGN KEY ("products_id") REFERENCES "public"."products"("id") ON DELETE cascade ON UPDATE no action;
|
|
||||||
ALTER TABLE "_articles_v" ADD CONSTRAINT "_articles_v_parent_id_articles_id_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."articles"("id") ON DELETE set null ON UPDATE no action;
|
|
||||||
ALTER TABLE "_articles_v" ADD CONSTRAINT "_articles_v_version_featured_image_id_media_id_fk" FOREIGN KEY ("version_featured_image_id") REFERENCES "public"."media"("id") ON DELETE set null ON UPDATE no action;
|
|
||||||
ALTER TABLE "_articles_v" ADD CONSTRAINT "_articles_v_version_author_id_users_id_fk" FOREIGN KEY ("version_author_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;
|
|
||||||
ALTER TABLE "_articles_v_texts" ADD CONSTRAINT "_articles_v_texts_parent_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."_articles_v"("id") ON DELETE cascade ON UPDATE no action;
|
|
||||||
ALTER TABLE "_articles_v_rels" ADD CONSTRAINT "_articles_v_rels_parent_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."_articles_v"("id") ON DELETE cascade ON UPDATE no action;
|
|
||||||
ALTER TABLE "_articles_v_rels" ADD CONSTRAINT "_articles_v_rels_articles_fk" FOREIGN KEY ("articles_id") REFERENCES "public"."articles"("id") ON DELETE cascade ON UPDATE no action;
|
|
||||||
ALTER TABLE "_articles_v_rels" ADD CONSTRAINT "_articles_v_rels_products_fk" FOREIGN KEY ("products_id") REFERENCES "public"."products"("id") ON DELETE cascade ON UPDATE no action;
|
|
||||||
ALTER TABLE "logs" ADD CONSTRAINT "logs_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;
|
|
||||||
ALTER TABLE "payload_jobs_log" ADD CONSTRAINT "payload_jobs_log_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."payload_jobs"("id") ON DELETE cascade ON UPDATE no action;
|
|
||||||
ALTER TABLE "hero_slider_slides" ADD CONSTRAINT "hero_slider_slides_image_id_media_id_fk" FOREIGN KEY ("image_id") REFERENCES "public"."media"("id") ON DELETE set null 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 "hero_slider_slides" ADD CONSTRAINT "hero_slider_slides_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."hero_slider"("id") ON DELETE cascade ON UPDATE no action;
|
|
||||||
ALTER TABLE "product_recommendations_lists" ADD CONSTRAINT "product_recommendations_lists_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."product_recommendations"("id") ON DELETE cascade ON UPDATE no action;
|
|
||||||
ALTER TABLE "product_recommendations_rels" ADD CONSTRAINT "product_recommendations_rels_parent_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."product_recommendations"("id") ON DELETE cascade ON UPDATE no action;
|
|
||||||
ALTER TABLE "product_recommendations_rels" ADD CONSTRAINT "product_recommendations_rels_products_fk" FOREIGN KEY ("products_id") REFERENCES "public"."products"("id") ON DELETE cascade ON UPDATE no action;
|
|
||||||
CREATE INDEX "users_roles_order_idx" ON "users_roles" USING btree ("order");
|
|
||||||
CREATE INDEX "users_roles_parent_idx" ON "users_roles" USING btree ("parent_id");
|
|
||||||
CREATE INDEX "announcements_author_idx" ON "announcements" USING btree ("author_id");
|
|
||||||
CREATE INDEX "announcements_updated_at_idx" ON "announcements" USING btree ("updated_at");
|
|
||||||
CREATE INDEX "announcements_created_at_idx" ON "announcements" USING btree ("created_at");
|
|
||||||
CREATE UNIQUE INDEX "articles_slug_idx" ON "articles" USING btree ("slug");
|
|
||||||
CREATE INDEX "articles_featured_image_idx" ON "articles" USING btree ("featured_image_id");
|
|
||||||
CREATE INDEX "articles_author_idx" ON "articles" USING btree ("author_id");
|
|
||||||
CREATE INDEX "articles_updated_at_idx" ON "articles" USING btree ("updated_at");
|
|
||||||
CREATE INDEX "articles_created_at_idx" ON "articles" USING btree ("created_at");
|
|
||||||
CREATE INDEX "articles__status_idx" ON "articles" USING btree ("_status");
|
|
||||||
CREATE INDEX "articles_texts_order_parent" ON "articles_texts" USING btree ("order","parent_id");
|
|
||||||
CREATE INDEX "articles_rels_order_idx" ON "articles_rels" USING btree ("order");
|
|
||||||
CREATE INDEX "articles_rels_parent_idx" ON "articles_rels" USING btree ("parent_id");
|
|
||||||
CREATE INDEX "articles_rels_path_idx" ON "articles_rels" USING btree ("path");
|
|
||||||
CREATE INDEX "articles_rels_articles_id_idx" ON "articles_rels" USING btree ("articles_id");
|
|
||||||
CREATE INDEX "articles_rels_products_id_idx" ON "articles_rels" USING btree ("products_id");
|
|
||||||
CREATE INDEX "_articles_v_parent_idx" ON "_articles_v" USING btree ("parent_id");
|
|
||||||
CREATE INDEX "_articles_v_version_version_slug_idx" ON "_articles_v" USING btree ("version_slug");
|
|
||||||
CREATE INDEX "_articles_v_version_version_featured_image_idx" ON "_articles_v" USING btree ("version_featured_image_id");
|
|
||||||
CREATE INDEX "_articles_v_version_version_author_idx" ON "_articles_v" USING btree ("version_author_id");
|
|
||||||
CREATE INDEX "_articles_v_version_version_updated_at_idx" ON "_articles_v" USING btree ("version_updated_at");
|
|
||||||
CREATE INDEX "_articles_v_version_version_created_at_idx" ON "_articles_v" USING btree ("version_created_at");
|
|
||||||
CREATE INDEX "_articles_v_version_version__status_idx" ON "_articles_v" USING btree ("version__status");
|
|
||||||
CREATE INDEX "_articles_v_created_at_idx" ON "_articles_v" USING btree ("created_at");
|
|
||||||
CREATE INDEX "_articles_v_updated_at_idx" ON "_articles_v" USING btree ("updated_at");
|
|
||||||
CREATE INDEX "_articles_v_latest_idx" ON "_articles_v" USING btree ("latest");
|
|
||||||
CREATE INDEX "_articles_v_autosave_idx" ON "_articles_v" USING btree ("autosave");
|
|
||||||
CREATE INDEX "_articles_v_texts_order_parent" ON "_articles_v_texts" USING btree ("order","parent_id");
|
|
||||||
CREATE INDEX "_articles_v_rels_order_idx" ON "_articles_v_rels" USING btree ("order");
|
|
||||||
CREATE INDEX "_articles_v_rels_parent_idx" ON "_articles_v_rels" USING btree ("parent_id");
|
|
||||||
CREATE INDEX "_articles_v_rels_path_idx" ON "_articles_v_rels" USING btree ("path");
|
|
||||||
CREATE INDEX "_articles_v_rels_articles_id_idx" ON "_articles_v_rels" USING btree ("articles_id");
|
|
||||||
CREATE INDEX "_articles_v_rels_products_id_idx" ON "_articles_v_rels" USING btree ("products_id");
|
|
||||||
CREATE INDEX "logs_collection_idx" ON "logs" USING btree ("collection");
|
|
||||||
CREATE INDEX "logs_document_id_idx" ON "logs" USING btree ("document_id");
|
|
||||||
CREATE INDEX "logs_user_idx" ON "logs" USING btree ("user_id");
|
|
||||||
CREATE INDEX "logs_updated_at_idx" ON "logs" USING btree ("updated_at");
|
|
||||||
CREATE INDEX "logs_created_at_idx" ON "logs" USING btree ("created_at");
|
|
||||||
CREATE INDEX "payload_jobs_log_order_idx" ON "payload_jobs_log" USING btree ("_order");
|
|
||||||
CREATE INDEX "payload_jobs_log_parent_id_idx" ON "payload_jobs_log" USING btree ("_parent_id");
|
|
||||||
CREATE INDEX "payload_jobs_completed_at_idx" ON "payload_jobs" USING btree ("completed_at");
|
|
||||||
CREATE INDEX "payload_jobs_total_tried_idx" ON "payload_jobs" USING btree ("total_tried");
|
|
||||||
CREATE INDEX "payload_jobs_has_error_idx" ON "payload_jobs" USING btree ("has_error");
|
|
||||||
CREATE INDEX "payload_jobs_task_slug_idx" ON "payload_jobs" USING btree ("task_slug");
|
|
||||||
CREATE INDEX "payload_jobs_queue_idx" ON "payload_jobs" USING btree ("queue");
|
|
||||||
CREATE INDEX "payload_jobs_wait_until_idx" ON "payload_jobs" USING btree ("wait_until");
|
|
||||||
CREATE INDEX "payload_jobs_processing_idx" ON "payload_jobs" USING btree ("processing");
|
|
||||||
CREATE INDEX "payload_jobs_updated_at_idx" ON "payload_jobs" USING btree ("updated_at");
|
|
||||||
CREATE INDEX "payload_jobs_created_at_idx" ON "payload_jobs" USING btree ("created_at");
|
|
||||||
CREATE INDEX "hero_slider_slides_order_idx" ON "hero_slider_slides" USING btree ("_order");
|
|
||||||
CREATE INDEX "hero_slider_slides_parent_id_idx" ON "hero_slider_slides" USING btree ("_parent_id");
|
|
||||||
CREATE INDEX "hero_slider_slides_image_idx" ON "hero_slider_slides" USING btree ("image_id");
|
|
||||||
CREATE INDEX "hero_slider_slides_image_mobile_idx" ON "hero_slider_slides" USING btree ("image_mobile_id");
|
|
||||||
CREATE INDEX "product_recommendations_lists_order_idx" ON "product_recommendations_lists" USING btree ("_order");
|
|
||||||
CREATE INDEX "product_recommendations_lists_parent_id_idx" ON "product_recommendations_lists" USING btree ("_parent_id");
|
|
||||||
CREATE INDEX "product_recommendations_rels_order_idx" ON "product_recommendations_rels" USING btree ("order");
|
|
||||||
CREATE INDEX "product_recommendations_rels_parent_idx" ON "product_recommendations_rels" USING btree ("parent_id");
|
|
||||||
CREATE INDEX "product_recommendations_rels_path_idx" ON "product_recommendations_rels" USING btree ("path");
|
|
||||||
CREATE INDEX "product_recommendations_rels_products_id_idx" ON "product_recommendations_rels" USING btree ("products_id");
|
|
||||||
ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_announcements_fk" FOREIGN KEY ("announcements_id") REFERENCES "public"."announcements"("id") ON DELETE cascade ON UPDATE no action;
|
|
||||||
ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_articles_fk" FOREIGN KEY ("articles_id") REFERENCES "public"."articles"("id") ON DELETE cascade ON UPDATE no action;
|
|
||||||
ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_logs_fk" FOREIGN KEY ("logs_id") REFERENCES "public"."logs"("id") ON DELETE cascade ON UPDATE no action;
|
|
||||||
CREATE INDEX "payload_locked_documents_rels_announcements_id_idx" ON "payload_locked_documents_rels" USING btree ("announcements_id");
|
|
||||||
CREATE INDEX "payload_locked_documents_rels_articles_id_idx" ON "payload_locked_documents_rels" USING btree ("articles_id");
|
|
||||||
CREATE INDEX "payload_locked_documents_rels_logs_id_idx" ON "payload_locked_documents_rels" USING btree ("logs_id");`)
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
|
|
||||||
await db.execute(sql`
|
|
||||||
ALTER TABLE "users_roles" DISABLE ROW LEVEL SECURITY;
|
|
||||||
ALTER TABLE "announcements" DISABLE ROW LEVEL SECURITY;
|
|
||||||
ALTER TABLE "articles" DISABLE ROW LEVEL SECURITY;
|
|
||||||
ALTER TABLE "articles_texts" DISABLE ROW LEVEL SECURITY;
|
|
||||||
ALTER TABLE "articles_rels" DISABLE ROW LEVEL SECURITY;
|
|
||||||
ALTER TABLE "_articles_v" DISABLE ROW LEVEL SECURITY;
|
|
||||||
ALTER TABLE "_articles_v_texts" DISABLE ROW LEVEL SECURITY;
|
|
||||||
ALTER TABLE "_articles_v_rels" DISABLE ROW LEVEL SECURITY;
|
|
||||||
ALTER TABLE "logs" DISABLE ROW LEVEL SECURITY;
|
|
||||||
ALTER TABLE "payload_jobs_log" DISABLE ROW LEVEL SECURITY;
|
|
||||||
ALTER TABLE "payload_jobs" DISABLE ROW LEVEL SECURITY;
|
|
||||||
ALTER TABLE "admin_settings" DISABLE ROW LEVEL SECURITY;
|
|
||||||
ALTER TABLE "logs_manager" DISABLE ROW LEVEL SECURITY;
|
|
||||||
ALTER TABLE "hero_slider_slides" DISABLE ROW LEVEL SECURITY;
|
|
||||||
ALTER TABLE "hero_slider" DISABLE ROW LEVEL SECURITY;
|
|
||||||
ALTER TABLE "product_recommendations_lists" DISABLE ROW LEVEL SECURITY;
|
|
||||||
ALTER TABLE "product_recommendations" DISABLE ROW LEVEL SECURITY;
|
|
||||||
ALTER TABLE "product_recommendations_rels" DISABLE ROW LEVEL SECURITY;
|
|
||||||
DROP TABLE "users_roles" CASCADE;
|
|
||||||
DROP TABLE "announcements" CASCADE;
|
|
||||||
DROP TABLE "articles" CASCADE;
|
|
||||||
DROP TABLE "articles_texts" CASCADE;
|
|
||||||
DROP TABLE "articles_rels" CASCADE;
|
|
||||||
DROP TABLE "_articles_v" CASCADE;
|
|
||||||
DROP TABLE "_articles_v_texts" CASCADE;
|
|
||||||
DROP TABLE "_articles_v_rels" CASCADE;
|
|
||||||
DROP TABLE "logs" CASCADE;
|
|
||||||
DROP TABLE "payload_jobs_log" CASCADE;
|
|
||||||
DROP TABLE "payload_jobs" CASCADE;
|
|
||||||
DROP TABLE "admin_settings" CASCADE;
|
|
||||||
DROP TABLE "logs_manager" CASCADE;
|
|
||||||
DROP TABLE "hero_slider_slides" CASCADE;
|
|
||||||
DROP TABLE "hero_slider" CASCADE;
|
|
||||||
DROP TABLE "product_recommendations_lists" CASCADE;
|
|
||||||
DROP TABLE "product_recommendations" CASCADE;
|
|
||||||
DROP TABLE "product_recommendations_rels" CASCADE;
|
|
||||||
ALTER TABLE "payload_locked_documents_rels" DROP CONSTRAINT "payload_locked_documents_rels_announcements_fk";
|
|
||||||
|
|
||||||
ALTER TABLE "payload_locked_documents_rels" DROP CONSTRAINT "payload_locked_documents_rels_articles_fk";
|
|
||||||
|
|
||||||
ALTER TABLE "payload_locked_documents_rels" DROP CONSTRAINT "payload_locked_documents_rels_logs_fk";
|
|
||||||
|
|
||||||
DROP INDEX "payload_locked_documents_rels_announcements_id_idx";
|
|
||||||
DROP INDEX "payload_locked_documents_rels_articles_id_idx";
|
|
||||||
DROP INDEX "payload_locked_documents_rels_logs_id_idx";
|
|
||||||
ALTER TABLE "products" DROP COLUMN "content";
|
|
||||||
ALTER TABLE "payload_locked_documents_rels" DROP COLUMN "announcements_id";
|
|
||||||
ALTER TABLE "payload_locked_documents_rels" DROP COLUMN "articles_id";
|
|
||||||
ALTER TABLE "payload_locked_documents_rels" DROP COLUMN "logs_id";
|
|
||||||
DROP TYPE "public"."enum_users_roles";
|
|
||||||
DROP TYPE "public"."enum_announcements_type";
|
|
||||||
DROP TYPE "public"."enum_announcements_status";
|
|
||||||
DROP TYPE "public"."enum_articles_status";
|
|
||||||
DROP TYPE "public"."enum_articles_category";
|
|
||||||
DROP TYPE "public"."enum__articles_v_version_status";
|
|
||||||
DROP TYPE "public"."enum__articles_v_version_category";
|
|
||||||
DROP TYPE "public"."enum_logs_action";
|
|
||||||
DROP TYPE "public"."enum_payload_jobs_log_task_slug";
|
|
||||||
DROP TYPE "public"."enum_payload_jobs_log_state";
|
|
||||||
DROP TYPE "public"."enum_payload_jobs_task_slug";`)
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,45 +0,0 @@
|
||||||
import { MigrateUpArgs, sql } from '@payloadcms/db-postgres'
|
|
||||||
|
|
||||||
export async function up({ db }: MigrateUpArgs): Promise<void> {
|
|
||||||
await db.execute(sql`
|
|
||||||
CREATE TYPE "public"."enum_preorder_products_status" AS ENUM('draft', 'published');
|
|
||||||
CREATE TABLE "preorder_products" (
|
|
||||||
"id" serial PRIMARY KEY NOT NULL,
|
|
||||||
"medusa_id" varchar NOT NULL,
|
|
||||||
"status" "enum_preorder_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 "preorder_products_rels" (
|
|
||||||
"id" serial PRIMARY KEY NOT NULL,
|
|
||||||
"order" integer,
|
|
||||||
"parent_id" integer NOT NULL,
|
|
||||||
"path" varchar NOT NULL,
|
|
||||||
"preorder_products_id" integer,
|
|
||||||
"products_id" integer
|
|
||||||
);
|
|
||||||
|
|
||||||
ALTER TABLE "payload_locked_documents_rels" ADD COLUMN "preorder_products_id" integer;
|
|
||||||
ALTER TABLE "product_recommendations_rels" ADD COLUMN "preorder_products_id" integer;
|
|
||||||
ALTER TABLE "preorder_products_rels" ADD CONSTRAINT "preorder_products_rels_parent_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."preorder_products"("id") ON DELETE cascade ON UPDATE no action;
|
|
||||||
ALTER TABLE "preorder_products_rels" ADD CONSTRAINT "preorder_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;
|
|
||||||
CREATE UNIQUE INDEX "preorder_products_medusa_id_idx" ON "preorder_products" USING btree ("medusa_id");
|
|
||||||
CREATE INDEX "preorder_products_updated_at_idx" ON "preorder_products" USING btree ("updated_at");
|
|
||||||
CREATE INDEX "preorder_products_created_at_idx" ON "preorder_products" USING btree ("created_at");
|
|
||||||
CREATE INDEX "preorder_products_rels_order_idx" ON "preorder_products_rels" USING btree ("order");
|
|
||||||
CREATE INDEX "preorder_products_rels_parent_idx" ON "preorder_products_rels" USING btree ("parent_id");
|
|
||||||
CREATE INDEX "preorder_products_rels_path_idx" ON "preorder_products_rels" USING btree ("path");
|
|
||||||
CREATE INDEX "preorder_products_rels_preorder_products_id_idx" ON "preorder_products_rels" USING btree ("preorder_products_id");
|
|
||||||
CREATE INDEX "preorder_products_rels_products_id_idx" ON "preorder_products_rels" USING btree ("products_id");
|
|
||||||
ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_preorder_products_fk" FOREIGN KEY ("preorder_products_id") REFERENCES "public"."preorder_products"("id") ON DELETE cascade ON UPDATE no action;
|
|
||||||
ALTER TABLE "product_recommendations_rels" ADD CONSTRAINT "product_recommendations_rels_preorder_products_fk" FOREIGN KEY ("preorder_products_id") REFERENCES "public"."preorder_products"("id") ON DELETE cascade ON UPDATE no action;
|
|
||||||
CREATE INDEX "payload_locked_documents_rels_preorder_products_id_idx" ON "payload_locked_documents_rels" USING btree ("preorder_products_id");
|
|
||||||
CREATE INDEX "product_recommendations_rels_preorder_products_id_idx" ON "product_recommendations_rels" USING btree ("preorder_products_id");`)
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,314 +0,0 @@
|
||||||
import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'
|
|
||||||
|
|
||||||
export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
|
|
||||||
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<void> {
|
|
||||||
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";`)
|
|
||||||
}
|
|
||||||
|
|
@ -1,250 +0,0 @@
|
||||||
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<void> {
|
|
||||||
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<void> {
|
|
||||||
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;
|
|
||||||
`)
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Baseline migration — represents the complete current schema state.
|
||||||
|
*
|
||||||
|
* All tables were originally created and evolved through dev-mode pushes
|
||||||
|
* and prior migrations (all applied). This file consolidates them into a
|
||||||
|
* single entry so Payload's migration tracker stays clean.
|
||||||
|
*
|
||||||
|
* For a fresh database, run `pnpm payload migrate:fresh` to let Payload
|
||||||
|
* rebuild the schema from the collection config, then run this migration
|
||||||
|
* to record the baseline as applied.
|
||||||
|
*/
|
||||||
|
export async function up({ db }: MigrateUpArgs): Promise<void> {
|
||||||
|
// Schema is already up-to-date; nothing to execute.
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function down({ db }: MigrateDownArgs): Promise<void> {
|
||||||
|
// No rollback for baseline.
|
||||||
|
}
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
import { MigrateUpArgs, sql } from '@payloadcms/db-postgres'
|
|
||||||
|
|
||||||
export async function up({ db }: MigrateUpArgs): Promise<void> {
|
|
||||||
await db.execute(sql`ALTER TABLE hero_slider_slides ADD COLUMN IF NOT EXISTS link TEXT;`)
|
|
||||||
|
|
||||||
await db.execute(
|
|
||||||
sql`UPDATE hero_slider_slides SET link = cta_link WHERE cta_link IS NOT NULL AND cta_enabled = true;`,
|
|
||||||
)
|
|
||||||
|
|
||||||
await db.execute(
|
|
||||||
sql`ALTER TABLE hero_slider_slides
|
|
||||||
DROP COLUMN IF EXISTS cta_enabled,
|
|
||||||
DROP COLUMN IF EXISTS cta_text,
|
|
||||||
DROP COLUMN IF EXISTS cta_style,
|
|
||||||
DROP COLUMN IF EXISTS cta_link,
|
|
||||||
DROP COLUMN IF EXISTS cta_new_tab,
|
|
||||||
DROP COLUMN IF EXISTS text_position,
|
|
||||||
DROP COLUMN IF EXISTS text_color,
|
|
||||||
DROP COLUMN IF EXISTS overlay,
|
|
||||||
DROP COLUMN IF EXISTS status;`,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
@ -1,45 +1,10 @@
|
||||||
import * as migration_20260208_171142 from './20260208_171142';
|
import * as migration_baseline from './baseline'
|
||||||
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 = [
|
export const migrations = [
|
||||||
{
|
{
|
||||||
up: migration_20260208_171142.up,
|
up: migration_baseline.up,
|
||||||
down: migration_20260208_171142.down,
|
down: migration_baseline.down,
|
||||||
name: '20260208_171142',
|
name: 'baseline',
|
||||||
},
|
},
|
||||||
{
|
]
|
||||||
up: migration_20260212_193303.up,
|
|
||||||
down: migration_20260212_193303.down,
|
|
||||||
name: '20260212_193303',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
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,
|
|
||||||
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',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
import { MigrateUpArgs, sql } from '@payloadcms/db-postgres'
|
|
||||||
|
|
||||||
export async function up({ db }: MigrateUpArgs): Promise<void> {
|
|
||||||
await db.execute(
|
|
||||||
sql`ALTER TABLE product_recommendations_lists
|
|
||||||
DROP COLUMN IF EXISTS slug,
|
|
||||||
DROP COLUMN IF EXISTS type,
|
|
||||||
DROP COLUMN IF EXISTS display_limit,
|
|
||||||
DROP COLUMN IF EXISTS show_view_all,
|
|
||||||
DROP COLUMN IF EXISTS view_all_link,
|
|
||||||
DROP COLUMN IF EXISTS layout,
|
|
||||||
DROP COLUMN IF EXISTS columns,
|
|
||||||
DROP COLUMN IF EXISTS show_price,
|
|
||||||
DROP COLUMN IF EXISTS show_rating,
|
|
||||||
DROP COLUMN IF EXISTS show_quick_view,
|
|
||||||
DROP COLUMN IF EXISTS status;`,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
@ -78,6 +78,7 @@ export interface Config {
|
||||||
'disassembly-areas': DisassemblyArea;
|
'disassembly-areas': DisassemblyArea;
|
||||||
'disassembly-components': DisassemblyComponent;
|
'disassembly-components': DisassemblyComponent;
|
||||||
'disassembly-linked-products': DisassemblyLinkedProduct;
|
'disassembly-linked-products': DisassemblyLinkedProduct;
|
||||||
|
precautions: Precaution;
|
||||||
'payload-kv': PayloadKv;
|
'payload-kv': PayloadKv;
|
||||||
'payload-jobs': PayloadJob;
|
'payload-jobs': PayloadJob;
|
||||||
'payload-locked-documents': PayloadLockedDocument;
|
'payload-locked-documents': PayloadLockedDocument;
|
||||||
|
|
@ -97,6 +98,7 @@ export interface Config {
|
||||||
'disassembly-areas': DisassemblyAreasSelect<false> | DisassemblyAreasSelect<true>;
|
'disassembly-areas': DisassemblyAreasSelect<false> | DisassemblyAreasSelect<true>;
|
||||||
'disassembly-components': DisassemblyComponentsSelect<false> | DisassemblyComponentsSelect<true>;
|
'disassembly-components': DisassemblyComponentsSelect<false> | DisassemblyComponentsSelect<true>;
|
||||||
'disassembly-linked-products': DisassemblyLinkedProductsSelect<false> | DisassemblyLinkedProductsSelect<true>;
|
'disassembly-linked-products': DisassemblyLinkedProductsSelect<false> | DisassemblyLinkedProductsSelect<true>;
|
||||||
|
precautions: PrecautionsSelect<false> | PrecautionsSelect<true>;
|
||||||
'payload-kv': PayloadKvSelect<false> | PayloadKvSelect<true>;
|
'payload-kv': PayloadKvSelect<false> | PayloadKvSelect<true>;
|
||||||
'payload-jobs': PayloadJobsSelect<false> | PayloadJobsSelect<true>;
|
'payload-jobs': PayloadJobsSelect<false> | PayloadJobsSelect<true>;
|
||||||
'payload-locked-documents': PayloadLockedDocumentsSelect<false> | PayloadLockedDocumentsSelect<true>;
|
'payload-locked-documents': PayloadLockedDocumentsSelect<false> | PayloadLockedDocumentsSelect<true>;
|
||||||
|
|
@ -241,6 +243,10 @@ export interface Product {
|
||||||
* 产品简介(纯文本,从 Medusa 同步,显示在卡片和列表页)
|
* 产品简介(纯文本,从 Medusa 同步,显示在卡片和列表页)
|
||||||
*/
|
*/
|
||||||
description?: string | null;
|
description?: string | null;
|
||||||
|
/**
|
||||||
|
* 访问密码(用于保护特定产品页面或内容)
|
||||||
|
*/
|
||||||
|
accessPassword?: string | null;
|
||||||
/**
|
/**
|
||||||
* 商品详细内容(富文本,由 Payload 编辑,展示在产品详情页)
|
* 商品详细内容(富文本,由 Payload 编辑,展示在产品详情页)
|
||||||
*/
|
*/
|
||||||
|
|
@ -318,6 +324,54 @@ export interface Product {
|
||||||
* 原产国(从 Medusa 同步)
|
* 原产国(从 Medusa 同步)
|
||||||
*/
|
*/
|
||||||
countryOfOrigin?: string | null;
|
countryOfOrigin?: string | null;
|
||||||
|
/**
|
||||||
|
* 产品项目状态列表,可直接在此添加和编辑
|
||||||
|
*/
|
||||||
|
projectStatuses?:
|
||||||
|
| {
|
||||||
|
/**
|
||||||
|
* 状态名称,例如:研发中、众筹中、量产中
|
||||||
|
*/
|
||||||
|
title: string;
|
||||||
|
/**
|
||||||
|
* 状态徽章标签(简短文字,展示在产品卡片上)
|
||||||
|
*/
|
||||||
|
badge?: string | null;
|
||||||
|
/**
|
||||||
|
* 状态简介
|
||||||
|
*/
|
||||||
|
description?: string | null;
|
||||||
|
/**
|
||||||
|
* 排序权重(数值越小越靠前)
|
||||||
|
*/
|
||||||
|
order?: number | null;
|
||||||
|
id?: string | null;
|
||||||
|
}[]
|
||||||
|
| null;
|
||||||
|
/**
|
||||||
|
* 引用通用注意事项(在《通用注意事项》集合中统一管理,可被多个产品复用)
|
||||||
|
*/
|
||||||
|
sharedPrecautions?: (string | Precaution)[] | null;
|
||||||
|
/**
|
||||||
|
* 产品专属注意事项,可直接在此添加和编辑
|
||||||
|
*/
|
||||||
|
precautions?:
|
||||||
|
| {
|
||||||
|
/**
|
||||||
|
* 注意事项标题,例如:安装注意事项、使用须知
|
||||||
|
*/
|
||||||
|
title: string;
|
||||||
|
/**
|
||||||
|
* 注意事项摘要
|
||||||
|
*/
|
||||||
|
summary?: string | null;
|
||||||
|
/**
|
||||||
|
* 排序权重(数值越小越靠前)
|
||||||
|
*/
|
||||||
|
order?: number | null;
|
||||||
|
id?: string | null;
|
||||||
|
}[]
|
||||||
|
| null;
|
||||||
/**
|
/**
|
||||||
* 💡 管理淘宝采购链接(仅后台显示,不通过 API 暴露)
|
* 💡 管理淘宝采购链接(仅后台显示,不通过 API 暴露)
|
||||||
*/
|
*/
|
||||||
|
|
@ -387,6 +441,10 @@ export interface PreorderProduct {
|
||||||
* 产品简介(纯文本,从 Medusa 同步,显示在卡片和列表页)
|
* 产品简介(纯文本,从 Medusa 同步,显示在卡片和列表页)
|
||||||
*/
|
*/
|
||||||
description?: string | null;
|
description?: string | null;
|
||||||
|
/**
|
||||||
|
* 访问密码(用于保护特定产品页面或内容)
|
||||||
|
*/
|
||||||
|
accessPassword?: string | null;
|
||||||
/**
|
/**
|
||||||
* 预购类型
|
* 预购类型
|
||||||
*/
|
*/
|
||||||
|
|
@ -488,6 +546,54 @@ export interface PreorderProduct {
|
||||||
* 原产国(从 Medusa 同步)
|
* 原产国(从 Medusa 同步)
|
||||||
*/
|
*/
|
||||||
countryOfOrigin?: string | null;
|
countryOfOrigin?: string | null;
|
||||||
|
/**
|
||||||
|
* 产品项目状态列表,可直接在此添加和编辑
|
||||||
|
*/
|
||||||
|
projectStatuses?:
|
||||||
|
| {
|
||||||
|
/**
|
||||||
|
* 状态名称,例如:研发中、众筹中、量产中
|
||||||
|
*/
|
||||||
|
title: string;
|
||||||
|
/**
|
||||||
|
* 状态徽章标签(简短文字,展示在产品卡片上)
|
||||||
|
*/
|
||||||
|
badge?: string | null;
|
||||||
|
/**
|
||||||
|
* 状态简介
|
||||||
|
*/
|
||||||
|
description?: string | null;
|
||||||
|
/**
|
||||||
|
* 排序权重(数值越小越靠前)
|
||||||
|
*/
|
||||||
|
order?: number | null;
|
||||||
|
id?: string | null;
|
||||||
|
}[]
|
||||||
|
| null;
|
||||||
|
/**
|
||||||
|
* 引用通用注意事项(在《通用注意事项》集合中统一管理,可被多个产品复用)
|
||||||
|
*/
|
||||||
|
sharedPrecautions?: (string | Precaution)[] | null;
|
||||||
|
/**
|
||||||
|
* 产品专属注意事项,可直接在此添加和编辑
|
||||||
|
*/
|
||||||
|
precautions?:
|
||||||
|
| {
|
||||||
|
/**
|
||||||
|
* 注意事项标题,例如:安装注意事项、使用须知
|
||||||
|
*/
|
||||||
|
title: string;
|
||||||
|
/**
|
||||||
|
* 注意事项摘要
|
||||||
|
*/
|
||||||
|
summary?: string | null;
|
||||||
|
/**
|
||||||
|
* 排序权重(数值越小越靠前)
|
||||||
|
*/
|
||||||
|
order?: number | null;
|
||||||
|
id?: string | null;
|
||||||
|
}[]
|
||||||
|
| null;
|
||||||
/**
|
/**
|
||||||
* 💡 管理淘宝采购链接(仅后台显示,不通过 API 暴露)
|
* 💡 管理淘宝采购链接(仅后台显示,不通过 API 暴露)
|
||||||
*/
|
*/
|
||||||
|
|
@ -513,6 +619,29 @@ export interface PreorderProduct {
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 管理通用注意事项,可被多个产品复用引用
|
||||||
|
*
|
||||||
|
* This interface was referenced by `Config`'s JSON-Schema
|
||||||
|
* via the `definition` "precautions".
|
||||||
|
*/
|
||||||
|
export interface Precaution {
|
||||||
|
/**
|
||||||
|
* 注意事项标题,例如:安装注意事项、使用须知
|
||||||
|
*/
|
||||||
|
title: string;
|
||||||
|
/**
|
||||||
|
* 注意事项摘要
|
||||||
|
*/
|
||||||
|
summary?: string | null;
|
||||||
|
/**
|
||||||
|
* 排序权重(数值越小越靠前)
|
||||||
|
*/
|
||||||
|
order?: number | null;
|
||||||
|
id: string;
|
||||||
|
updatedAt: string;
|
||||||
|
createdAt: string;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 管理系统公告和通知
|
* 管理系统公告和通知
|
||||||
*
|
*
|
||||||
|
|
@ -1004,6 +1133,10 @@ export interface PayloadLockedDocument {
|
||||||
| ({
|
| ({
|
||||||
relationTo: 'disassembly-linked-products';
|
relationTo: 'disassembly-linked-products';
|
||||||
value: number | DisassemblyLinkedProduct;
|
value: number | DisassemblyLinkedProduct;
|
||||||
|
} | null)
|
||||||
|
| ({
|
||||||
|
relationTo: 'precautions';
|
||||||
|
value: string | Precaution;
|
||||||
} | null);
|
} | null);
|
||||||
globalSlug?: string | null;
|
globalSlug?: string | null;
|
||||||
user: {
|
user: {
|
||||||
|
|
@ -1102,6 +1235,7 @@ export interface ProductsSelect<T extends boolean = true> {
|
||||||
startPrice?: T;
|
startPrice?: T;
|
||||||
lastSyncedAt?: T;
|
lastSyncedAt?: T;
|
||||||
description?: T;
|
description?: T;
|
||||||
|
accessPassword?: T;
|
||||||
content?: T;
|
content?: T;
|
||||||
relatedProducts?: T;
|
relatedProducts?: T;
|
||||||
tags?: T;
|
tags?: T;
|
||||||
|
|
@ -1115,6 +1249,24 @@ export interface ProductsSelect<T extends boolean = true> {
|
||||||
midCode?: T;
|
midCode?: T;
|
||||||
hsCode?: T;
|
hsCode?: T;
|
||||||
countryOfOrigin?: T;
|
countryOfOrigin?: T;
|
||||||
|
projectStatuses?:
|
||||||
|
| T
|
||||||
|
| {
|
||||||
|
title?: T;
|
||||||
|
badge?: T;
|
||||||
|
description?: T;
|
||||||
|
order?: T;
|
||||||
|
id?: T;
|
||||||
|
};
|
||||||
|
sharedPrecautions?: T;
|
||||||
|
precautions?:
|
||||||
|
| T
|
||||||
|
| {
|
||||||
|
title?: T;
|
||||||
|
summary?: T;
|
||||||
|
order?: T;
|
||||||
|
id?: T;
|
||||||
|
};
|
||||||
taobaoLinks?:
|
taobaoLinks?:
|
||||||
| T
|
| T
|
||||||
| {
|
| {
|
||||||
|
|
@ -1142,6 +1294,7 @@ export interface PreorderProductsSelect<T extends boolean = true> {
|
||||||
startPrice?: T;
|
startPrice?: T;
|
||||||
lastSyncedAt?: T;
|
lastSyncedAt?: T;
|
||||||
description?: T;
|
description?: T;
|
||||||
|
accessPassword?: T;
|
||||||
preorderType?: T;
|
preorderType?: T;
|
||||||
fundingGoal?: T;
|
fundingGoal?: T;
|
||||||
preorderStartDate?: T;
|
preorderStartDate?: T;
|
||||||
|
|
@ -1161,6 +1314,24 @@ export interface PreorderProductsSelect<T extends boolean = true> {
|
||||||
midCode?: T;
|
midCode?: T;
|
||||||
hsCode?: T;
|
hsCode?: T;
|
||||||
countryOfOrigin?: T;
|
countryOfOrigin?: T;
|
||||||
|
projectStatuses?:
|
||||||
|
| T
|
||||||
|
| {
|
||||||
|
title?: T;
|
||||||
|
badge?: T;
|
||||||
|
description?: T;
|
||||||
|
order?: T;
|
||||||
|
id?: T;
|
||||||
|
};
|
||||||
|
sharedPrecautions?: T;
|
||||||
|
precautions?:
|
||||||
|
| T
|
||||||
|
| {
|
||||||
|
title?: T;
|
||||||
|
summary?: T;
|
||||||
|
order?: T;
|
||||||
|
id?: T;
|
||||||
|
};
|
||||||
taobaoLinks?:
|
taobaoLinks?:
|
||||||
| T
|
| T
|
||||||
| {
|
| {
|
||||||
|
|
@ -1294,6 +1465,18 @@ export interface DisassemblyLinkedProductsSelect<T extends boolean = true> {
|
||||||
updatedAt?: T;
|
updatedAt?: T;
|
||||||
createdAt?: T;
|
createdAt?: T;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* This interface was referenced by `Config`'s JSON-Schema
|
||||||
|
* via the `definition` "precautions_select".
|
||||||
|
*/
|
||||||
|
export interface PrecautionsSelect<T extends boolean = true> {
|
||||||
|
title?: T;
|
||||||
|
summary?: T;
|
||||||
|
order?: T;
|
||||||
|
id?: T;
|
||||||
|
updatedAt?: T;
|
||||||
|
createdAt?: T;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* This interface was referenced by `Config`'s JSON-Schema
|
* This interface was referenced by `Config`'s JSON-Schema
|
||||||
* via the `definition` "payload-kv_select".
|
* via the `definition` "payload-kv_select".
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ import sharp from 'sharp'
|
||||||
|
|
||||||
import { Users } from './collections/Users'
|
import { Users } from './collections/Users'
|
||||||
import { Media } from './collections/Media'
|
import { Media } from './collections/Media'
|
||||||
import { Products } from './collections/Products'
|
import { Products } from './collections/products/Products'
|
||||||
import { PreorderProducts } from './collections/PreorderProducts'
|
import { PreorderProducts } from './collections/products/PreorderProducts'
|
||||||
import { Announcements } from './collections/Announcements'
|
import { Announcements } from './collections/Announcements'
|
||||||
import { Articles } from './collections/Articles'
|
import { Articles } from './collections/Articles'
|
||||||
import { Logs } from './collections/Logs'
|
import { Logs } from './collections/Logs'
|
||||||
|
|
@ -16,6 +16,7 @@ import { DisassemblyPages } from './collections/disassembly/DisassemblyPages'
|
||||||
import { DisassemblyAreas } from './collections/disassembly/DisassemblyAreas'
|
import { DisassemblyAreas } from './collections/disassembly/DisassemblyAreas'
|
||||||
import { DisassemblyComponents } from './collections/disassembly/DisassemblyComponents'
|
import { DisassemblyComponents } from './collections/disassembly/DisassemblyComponents'
|
||||||
import { DisassemblyLinkedProducts } from './collections/disassembly/DisassemblyLinkedProducts'
|
import { DisassemblyLinkedProducts } from './collections/disassembly/DisassemblyLinkedProducts'
|
||||||
|
import { Precautions } from './collections/Precautions'
|
||||||
import { AdminSettings } from './globals/AdminSettings'
|
import { AdminSettings } from './globals/AdminSettings'
|
||||||
import { LogsManager } from './globals/LogsManager'
|
import { LogsManager } from './globals/LogsManager'
|
||||||
import { HeroSlider } from './globals/HeroSlider'
|
import { HeroSlider } from './globals/HeroSlider'
|
||||||
|
|
@ -61,7 +62,7 @@ export default buildConfig({
|
||||||
},
|
},
|
||||||
fallbackLanguage: 'zh',
|
fallbackLanguage: 'zh',
|
||||||
},
|
},
|
||||||
collections: [Users, Media, Products, PreorderProducts, Announcements, Articles, Logs, DisassemblyPages, DisassemblyAreas, DisassemblyComponents, DisassemblyLinkedProducts],
|
collections: [Users, Media, Products, PreorderProducts, Announcements, Articles, Logs, DisassemblyPages, DisassemblyAreas, DisassemblyComponents, DisassemblyLinkedProducts, Precautions],
|
||||||
globals: [AdminSettings, LogsManager, HeroSlider, ProductRecommendations, SiteAccess],
|
globals: [AdminSettings, LogsManager, HeroSlider, ProductRecommendations, SiteAccess],
|
||||||
editor: lexicalEditor(),
|
editor: lexicalEditor(),
|
||||||
secret: process.env.PAYLOAD_SECRET || '',
|
secret: process.env.PAYLOAD_SECRET || '',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue