From e5bb50015e78bcd89f5eafea2d80d73799f343ee Mon Sep 17 00:00:00 2001 From: Li1304553726 <1304553726@qq.com> Date: Thu, 5 Jun 2025 15:44:06 +0800 Subject: [PATCH] add --- .env.example | 1 + README.md | 3 +- apps/backend/src/adapters/storage-adapter.ts | 2 +- apps/web/app/page.tsx | 2 +- apps/web/app/upload/page.tsx | 3 +- apps/web/components/FileUpload.tsx | 3 +- apps/web/tsconfig.json | 13 +- dockers/cache-redis.yml | 4 +- dockers/database-postgres.yml | 10 +- dockers/search-elasticsearch.yml | 6 +- dockers/storage-minio.yml | 8 +- .../migrations/20250604033441_/migration.sql | 385 ++++++++++++++++++ .../migrations/20250604044202_y/migration.sql | 28 ++ .../migrations/20250604044608_y/migration.sql | 14 + .../migrations/20250604044641_y/migration.sql | 22 + .../migrations/20250604072756_y/migration.sql | 9 + packages/db/prisma/schema.prisma | 22 + pnpm-lock.yaml | 99 ----- 18 files changed, 510 insertions(+), 124 deletions(-) create mode 100644 packages/db/prisma/migrations/20250604033441_/migration.sql create mode 100644 packages/db/prisma/migrations/20250604044202_y/migration.sql create mode 100644 packages/db/prisma/migrations/20250604044608_y/migration.sql create mode 100644 packages/db/prisma/migrations/20250604044641_y/migration.sql create mode 100644 packages/db/prisma/migrations/20250604072756_y/migration.sql diff --git a/.env.example b/.env.example index a3b02d4..13843a9 100644 --- a/.env.example +++ b/.env.example @@ -10,6 +10,7 @@ POSTGRES_PASSWORD=Letusdoit123 # Redis 配置 REDIS_VERSION=7.2.4 +# REDIS_VERSION=latest REDIS_PASSWORD=nice # MinIO 配置 diff --git a/README.md b/README.md index 047a08a..46f3a93 100644 --- a/README.md +++ b/README.md @@ -197,8 +197,7 @@ pnpm build:web # 构建前端 pnpm build:backend # 构建后端 # 数据库 -pnpm db:generate # 生成 Prisma 客户端 -pnpm db:migrate # 运行数据库迁移 +pnpm db:generate # 运行数据库迁移 pnpm db:seed # 填充种子数据 pnpm db:studio # 打开 Prisma Studio diff --git a/apps/backend/src/adapters/storage-adapter.ts b/apps/backend/src/adapters/storage-adapter.ts index 1366cb7..6fdc75d 100644 --- a/apps/backend/src/adapters/storage-adapter.ts +++ b/apps/backend/src/adapters/storage-adapter.ts @@ -81,7 +81,7 @@ export class PrismaDatabaseAdapter implements DatabaseAdapter { data: { fileId: data.fileId, title: data.filename, - type: data.mimeType, + type: data.mimeType , storageType: data.storageType, status: data.status || 'UPLOADING', meta: { diff --git a/apps/web/app/page.tsx b/apps/web/app/page.tsx index 4947d39..99398f2 100644 --- a/apps/web/app/page.tsx +++ b/apps/web/app/page.tsx @@ -1,5 +1,5 @@ 'use client'; export default function HomePage() { - return <>; + return <>sss; } diff --git a/apps/web/app/upload/page.tsx b/apps/web/app/upload/page.tsx index cef182f..20da239 100644 --- a/apps/web/app/upload/page.tsx +++ b/apps/web/app/upload/page.tsx @@ -3,7 +3,6 @@ import { FileUpload } from '../../components/FileUpload'; import { FileDownload } from '../../components/FileDownload'; import { AdvancedFileDownload } from '../../components/AdvancedFileDownload'; import { DownloadTester } from '../../components/DownloadTester'; - export default function UploadPage() { return (
@@ -24,7 +23,7 @@ export default function UploadPage() {

🔧 下载测试

- +z
{/* 基础下载组件 */}
diff --git a/apps/web/components/FileUpload.tsx b/apps/web/components/FileUpload.tsx index ce8670d..b53db5b 100644 --- a/apps/web/components/FileUpload.tsx +++ b/apps/web/components/FileUpload.tsx @@ -21,7 +21,7 @@ export function FileUpload() { for (let i = 0; i < files.length; i++) { const file = files[i]; - + if (!file) continue; try { const result = await handleFileUpload( file, @@ -89,7 +89,6 @@ export function FileUpload() { return (

文件上传

- {/* 服务器信息 */}

diff --git a/apps/web/tsconfig.json b/apps/web/tsconfig.json index 0df2b22..657f2ef 100644 --- a/apps/web/tsconfig.json +++ b/apps/web/tsconfig.json @@ -3,9 +3,14 @@ "compilerOptions": { "baseUrl": ".", "paths": { - "@/*": ["./*"], - "@repo/backend/*": ["../backend/src/*"], + "@/*": [ + "./*" + ], + "@repo/backend/*": [ + "../backend/src/*" + ] }, + "jsx": "preserve", "plugins": [ { "name": "next" @@ -19,5 +24,7 @@ "**/*.tsx", ".next/types/**/*.ts" ], - "exclude": ["node_modules"] + "exclude": [ + "node_modules" + ] } diff --git a/dockers/cache-redis.yml b/dockers/cache-redis.yml index 9e11be7..ce327cb 100644 --- a/dockers/cache-redis.yml +++ b/dockers/cache-redis.yml @@ -1,6 +1,6 @@ services: redis: - image: redis:${REDIS_VERSION:-7.2.4} + image: redis:latest container_name: redis restart: always ports: @@ -23,5 +23,5 @@ volumes: driver: local driver_opts: type: none - device: ${PWD}/volumes/redis + device: /opt/projects/nice/volumes/redis o: bind diff --git a/dockers/database-postgres.yml b/dockers/database-postgres.yml index 27d324c..62762ac 100644 --- a/dockers/database-postgres.yml +++ b/dockers/database-postgres.yml @@ -1,13 +1,13 @@ services: db: - image: postgres:${POSTGRES_VERSION:-16} + image: postgres:latest container_name: postgres ports: - '5432:5432' environment: - - POSTGRES_DB=${POSTGRES_DB:-nice_db} - - POSTGRES_USER=${POSTGRES_USER:-nice_user} - - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-nice_password} + - POSTGRES_DB=db + - POSTGRES_USER=nice + - POSTGRES_PASSWORD=nice1234 volumes: - ./volumes/postgres:/var/lib/postgresql/data # - type: volume @@ -27,5 +27,5 @@ volumes: driver: local driver_opts: type: none - device: ${PWD}/volumes/postgres + device: /opt/projects/nice/volumes/postgres o: bind diff --git a/dockers/search-elasticsearch.yml b/dockers/search-elasticsearch.yml index feda168..5494fd8 100644 --- a/dockers/search-elasticsearch.yml +++ b/dockers/search-elasticsearch.yml @@ -1,6 +1,6 @@ services: elasticsearch: - image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTIC_VERSION:-8.12.2} + image: docker.elastic.co/elasticsearch/elasticsearch:9.0.1 container_name: elasticsearch restart: always ports: @@ -11,7 +11,7 @@ services: environment: - discovery.type=single-node - xpack.security.enabled=true - - ELASTIC_PASSWORD=${ELASTIC_PASSWORD:-nice_elastic_password} + - ELASTIC_PASSWORD=nice_elastic_password - 'ES_JAVA_OPTS=-Xms512m -Xmx512m' volumes: - type: volume @@ -32,5 +32,5 @@ volumes: driver: local driver_opts: type: none - device: ${PWD}/volumes/elasticsearch + device: /opt/projects/nice/volumes/elasticsearch o: bind diff --git a/dockers/storage-minio.yml b/dockers/storage-minio.yml index 1040479..e1cd74c 100644 --- a/dockers/storage-minio.yml +++ b/dockers/storage-minio.yml @@ -1,6 +1,6 @@ services: minio: - image: minio/minio:${MINIO_VERSION:-RELEASE.2024-04-18T19-09-19Z} + image: minio/minio container_name: minio restart: always ports: @@ -9,8 +9,8 @@ services: networks: - nice-net environment: - - MINIO_ACCESS_KEY=${MINIO_ACCESS_KEY:-nice_minio_access} - - MINIO_SECRET_KEY=${MINIO_SECRET_KEY:-nice_minio_secret} + - MINIO_ACCESS_KEY=nice1234 + - MINIO_SECRET_KEY=nice1234 volumes: - ./volumes/minio:/data command: server /data --console-address ":9001" @@ -25,5 +25,5 @@ volumes: driver: local driver_opts: type: none - device: ${PWD}/volumes/minio + device: /opt/projects/nice/volumes/minio o: bind diff --git a/packages/db/prisma/migrations/20250604033441_/migration.sql b/packages/db/prisma/migrations/20250604033441_/migration.sql new file mode 100644 index 0000000..a31f8b9 --- /dev/null +++ b/packages/db/prisma/migrations/20250604033441_/migration.sql @@ -0,0 +1,385 @@ +/* + Warnings: + + - You are about to drop the column `avatar` on the `users` table. All the data in the column will be lost. + - You are about to drop the column `created_time` on the `users` table. All the data in the column will be lost. + - You are about to drop the column `deactivated_time` on the `users` table. All the data in the column will be lost. + - You are about to drop the column `deleted_time` on the `users` table. All the data in the column will be lost. + - You are about to drop the column `is_admin` on the `users` table. All the data in the column will be lost. + - You are about to drop the column `is_system` on the `users` table. All the data in the column will be lost. + - You are about to drop the column `last_modified_time` on the `users` table. All the data in the column will be lost. + - You are about to drop the column `last_sign_time` on the `users` table. All the data in the column will be lost. + - You are about to drop the column `password` on the `users` table. All the data in the column will be lost. + - You are about to drop the column `phone` on the `users` table. All the data in the column will be lost. + - You are about to drop the column `salt` on the `users` table. All the data in the column will be lost. + - You are about to drop the `attachments` table. If the table is not empty, all the data it contains will be lost. + - You are about to drop the `notification` table. If the table is not empty, all the data it contains will be lost. + - You are about to drop the `oidc_clients` table. If the table is not empty, all the data it contains will be lost. + - You are about to drop the `resource` table. If the table is not empty, all the data it contains will be lost. + - You are about to drop the `setting` table. If the table is not empty, all the data it contains will be lost. + - You are about to drop the `trash` table. If the table is not empty, all the data it contains will be lost. + - You are about to drop the `user_last_visit` table. If the table is not empty, all the data it contains will be lost. + - A unique constraint covering the columns `[username]` on the table `users` will be added. If there are existing duplicate values, this will fail. + - Added the required column `updatedAt` to the `users` table without a default value. This is not possible if the table is not empty. + - Added the required column `username` to the `users` table without a default value. This is not possible if the table is not empty. + +*/ +-- CreateEnum +CREATE TYPE "Status" AS ENUM ('ACTIVE', 'INACTIVE'); + +-- CreateEnum +CREATE TYPE "SourceType" AS ENUM ('DATABASE', 'API', 'FILE', 'ERP', 'MES', 'IOT', 'STREAM'); + +-- CreateEnum +CREATE TYPE "PipelineType" AS ENUM ('SYNC', 'TRANSFORM', 'STREAM', 'HYBRID'); + +-- CreateEnum +CREATE TYPE "ExecutionStatus" AS ENUM ('PENDING', 'RUNNING', 'SUCCESS', 'FAILED', 'CANCELLED'); + +-- CreateEnum +CREATE TYPE "DataFormat" AS ENUM ('PARQUET', 'JSON', 'CSV', 'AVRO', 'DELTA'); + +-- CreateEnum +CREATE TYPE "AssetType" AS ENUM ('BATCH', 'STREAM', 'TABLE', 'VIEW', 'MODEL'); + +-- CreateEnum +CREATE TYPE "AssetStatus" AS ENUM ('ACTIVE', 'ARCHIVED', 'DEPRECATED'); + +-- CreateEnum +CREATE TYPE "QueryEngine" AS ENUM ('DUCKDB', 'ATHENA', 'SPARK', 'TRINO'); + +-- CreateEnum +CREATE TYPE "QueryStatus" AS ENUM ('PENDING', 'RUNNING', 'SUCCESS', 'FAILED', 'CANCELLED'); + +-- CreateEnum +CREATE TYPE "EntityType" AS ENUM ('PERSON', 'EQUIPMENT', 'FACILITY', 'MATERIAL', 'ORGANIZATION', 'PROJECT', 'CUSTOM'); + +-- CreateEnum +CREATE TYPE "LineageStatus" AS ENUM ('ACTIVE', 'ARCHIVED'); + +-- DropIndex +DROP INDEX "users_phone_key"; + +-- AlterTable +ALTER TABLE "users" DROP COLUMN "avatar", +DROP COLUMN "created_time", +DROP COLUMN "deactivated_time", +DROP COLUMN "deleted_time", +DROP COLUMN "is_admin", +DROP COLUMN "is_system", +DROP COLUMN "last_modified_time", +DROP COLUMN "last_sign_time", +DROP COLUMN "password", +DROP COLUMN "phone", +DROP COLUMN "salt", +ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, +ADD COLUMN "roles" JSONB, +ADD COLUMN "status" "Status" NOT NULL DEFAULT 'ACTIVE', +ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL, +ADD COLUMN "username" TEXT NOT NULL; + +-- DropTable +DROP TABLE "attachments"; + +-- DropTable +DROP TABLE "notification"; + +-- DropTable +DROP TABLE "oidc_clients"; + +-- DropTable +DROP TABLE "resource"; + +-- DropTable +DROP TABLE "setting"; + +-- DropTable +DROP TABLE "trash"; + +-- DropTable +DROP TABLE "user_last_visit"; + +-- CreateTable +CREATE TABLE "data_sources" ( + "id" TEXT NOT NULL, + "name" TEXT NOT NULL, + "code" TEXT NOT NULL, + "type" "SourceType" NOT NULL, + "config" JSONB NOT NULL, + "description" TEXT, + "status" "Status" NOT NULL DEFAULT 'ACTIVE', + "schemaVersion" TEXT DEFAULT '1.0', + "lastSynced" TIMESTAMP(3), + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "data_sources_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "pipelines" ( + "id" TEXT NOT NULL, + "name" TEXT NOT NULL, + "type" "PipelineType" NOT NULL, + "schedule" TEXT, + "config" JSONB NOT NULL, + "description" TEXT, + "status" "Status" NOT NULL DEFAULT 'ACTIVE', + "dataSourceId" TEXT, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "pipelines_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "pipeline_executions" ( + "id" TEXT NOT NULL, + "executionId" TEXT NOT NULL, + "status" "ExecutionStatus" NOT NULL DEFAULT 'PENDING', + "inputRecords" INTEGER NOT NULL DEFAULT 0, + "outputRecords" INTEGER NOT NULL DEFAULT 0, + "errorRecords" INTEGER NOT NULL DEFAULT 0, + "startedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "completedAt" TIMESTAMP(3), + "duration" INTEGER, + "metadata" JSONB, + "errorMsg" TEXT, + "pipelineId" TEXT NOT NULL, + + CONSTRAINT "pipeline_executions_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "data_assets" ( + "id" TEXT NOT NULL, + "assetId" TEXT NOT NULL, + "name" TEXT NOT NULL, + "type" "AssetType" NOT NULL DEFAULT 'BATCH', + "format" "DataFormat" NOT NULL DEFAULT 'PARQUET', + "storageConfig" JSONB NOT NULL, + "schema" JSONB, + "partitions" JSONB, + "size" BIGINT, + "recordCount" BIGINT, + "qualityScore" DOUBLE PRECISION, + "executionId" TEXT, + "status" "AssetStatus" NOT NULL DEFAULT 'ACTIVE', + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "data_assets_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "queries" ( + "id" TEXT NOT NULL, + "queryId" TEXT NOT NULL, + "sql" TEXT NOT NULL, + "engine" "QueryEngine" NOT NULL DEFAULT 'DUCKDB', + "status" "QueryStatus" NOT NULL DEFAULT 'PENDING', + "resultCount" BIGINT, + "resultPath" TEXT, + "duration" INTEGER, + "errorMsg" TEXT, + "tags" JSONB, + "assetId" TEXT NOT NULL, + "userId" TEXT, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "completedAt" TIMESTAMP(3), + + CONSTRAINT "queries_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "entities" ( + "id" TEXT NOT NULL, + "code" TEXT NOT NULL, + "name" TEXT NOT NULL, + "type" "EntityType" NOT NULL, + "attributes" JSONB, + "status" "Status" NOT NULL DEFAULT 'ACTIVE', + "parentId" TEXT, + "path" TEXT, + "level" INTEGER, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "entities_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "entity_relations" ( + "id" TEXT NOT NULL, + "sourceId" TEXT NOT NULL, + "targetId" TEXT NOT NULL, + "relationship" TEXT NOT NULL, + "attributes" JSONB, + "startDate" TIMESTAMP(3), + "endDate" TIMESTAMP(3), + "metadata" JSONB, + "status" "Status" NOT NULL DEFAULT 'ACTIVE', + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "entity_relations_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "lineage_records" ( + "id" TEXT NOT NULL, + "sourceType" TEXT NOT NULL, + "sourceId" TEXT NOT NULL, + "targetType" TEXT NOT NULL, + "targetId" TEXT NOT NULL, + "relationship" TEXT NOT NULL, + "metadata" JSONB, + "executionId" TEXT, + "entityId" TEXT, + "status" "LineageStatus" NOT NULL DEFAULT 'ACTIVE', + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "lineage_records_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "quality_rules" ( + "id" TEXT NOT NULL, + "name" TEXT NOT NULL, + "description" TEXT, + "rule" JSONB NOT NULL, + "threshold" DOUBLE PRECISION, + "entityType" TEXT, + "entityId" TEXT, + "status" "Status" NOT NULL DEFAULT 'ACTIVE', + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "quality_rules_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "data_catalogs" ( + "id" TEXT NOT NULL, + "name" TEXT NOT NULL, + "description" TEXT, + "tags" JSONB, + "owner" TEXT, + "category" TEXT, + "sensitivity" TEXT, + "assetType" TEXT NOT NULL, + "assetId" TEXT NOT NULL, + "status" "Status" NOT NULL DEFAULT 'ACTIVE', + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "data_catalogs_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "data_sources_code_key" ON "data_sources"("code"); + +-- CreateIndex +CREATE UNIQUE INDEX "pipeline_executions_executionId_key" ON "pipeline_executions"("executionId"); + +-- CreateIndex +CREATE UNIQUE INDEX "data_assets_assetId_key" ON "data_assets"("assetId"); + +-- CreateIndex +CREATE INDEX "data_assets_type_status_idx" ON "data_assets"("type", "status"); + +-- CreateIndex +CREATE INDEX "data_assets_createdAt_idx" ON "data_assets"("createdAt"); + +-- CreateIndex +CREATE UNIQUE INDEX "queries_queryId_key" ON "queries"("queryId"); + +-- CreateIndex +CREATE INDEX "queries_status_createdAt_idx" ON "queries"("status", "createdAt"); + +-- CreateIndex +CREATE UNIQUE INDEX "entities_code_key" ON "entities"("code"); + +-- CreateIndex +CREATE INDEX "entities_type_status_idx" ON "entities"("type", "status"); + +-- CreateIndex +CREATE INDEX "entities_code_idx" ON "entities"("code"); + +-- CreateIndex +CREATE INDEX "entities_type_code_idx" ON "entities"("type", "code"); + +-- CreateIndex +CREATE INDEX "entities_parentId_idx" ON "entities"("parentId"); + +-- CreateIndex +CREATE INDEX "entities_path_idx" ON "entities"("path"); + +-- CreateIndex +CREATE INDEX "entities_type_parentId_idx" ON "entities"("type", "parentId"); + +-- CreateIndex +CREATE INDEX "entities_level_idx" ON "entities"("level"); + +-- CreateIndex +CREATE INDEX "entity_relations_sourceId_idx" ON "entity_relations"("sourceId"); + +-- CreateIndex +CREATE INDEX "entity_relations_targetId_idx" ON "entity_relations"("targetId"); + +-- CreateIndex +CREATE INDEX "entity_relations_relationship_idx" ON "entity_relations"("relationship"); + +-- CreateIndex +CREATE INDEX "entity_relations_sourceId_relationship_idx" ON "entity_relations"("sourceId", "relationship"); + +-- CreateIndex +CREATE INDEX "entity_relations_targetId_relationship_idx" ON "entity_relations"("targetId", "relationship"); + +-- CreateIndex +CREATE INDEX "entity_relations_relationship_status_idx" ON "entity_relations"("relationship", "status"); + +-- CreateIndex +CREATE UNIQUE INDEX "entity_relations_sourceId_targetId_relationship_key" ON "entity_relations"("sourceId", "targetId", "relationship"); + +-- CreateIndex +CREATE INDEX "lineage_records_relationship_idx" ON "lineage_records"("relationship"); + +-- CreateIndex +CREATE UNIQUE INDEX "lineage_records_sourceType_sourceId_targetType_targetId_key" ON "lineage_records"("sourceType", "sourceId", "targetType", "targetId"); + +-- CreateIndex +CREATE INDEX "data_catalogs_category_idx" ON "data_catalogs"("category"); + +-- CreateIndex +CREATE UNIQUE INDEX "data_catalogs_assetType_assetId_key" ON "data_catalogs"("assetType", "assetId"); + +-- CreateIndex +CREATE UNIQUE INDEX "users_username_key" ON "users"("username"); + +-- AddForeignKey +ALTER TABLE "pipelines" ADD CONSTRAINT "pipelines_dataSourceId_fkey" FOREIGN KEY ("dataSourceId") REFERENCES "data_sources"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "pipeline_executions" ADD CONSTRAINT "pipeline_executions_pipelineId_fkey" FOREIGN KEY ("pipelineId") REFERENCES "pipelines"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "data_assets" ADD CONSTRAINT "data_assets_executionId_fkey" FOREIGN KEY ("executionId") REFERENCES "pipeline_executions"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "queries" ADD CONSTRAINT "queries_assetId_fkey" FOREIGN KEY ("assetId") REFERENCES "data_assets"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "entities" ADD CONSTRAINT "entities_parentId_fkey" FOREIGN KEY ("parentId") REFERENCES "entities"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "entity_relations" ADD CONSTRAINT "entity_relations_sourceId_fkey" FOREIGN KEY ("sourceId") REFERENCES "entities"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "entity_relations" ADD CONSTRAINT "entity_relations_targetId_fkey" FOREIGN KEY ("targetId") REFERENCES "entities"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "lineage_records" ADD CONSTRAINT "lineage_records_executionId_fkey" FOREIGN KEY ("executionId") REFERENCES "pipeline_executions"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "lineage_records" ADD CONSTRAINT "lineage_records_entityId_fkey" FOREIGN KEY ("entityId") REFERENCES "entities"("id") ON DELETE SET NULL ON UPDATE CASCADE; diff --git a/packages/db/prisma/migrations/20250604044202_y/migration.sql b/packages/db/prisma/migrations/20250604044202_y/migration.sql new file mode 100644 index 0000000..1e4adf9 --- /dev/null +++ b/packages/db/prisma/migrations/20250604044202_y/migration.sql @@ -0,0 +1,28 @@ +-- CreateTable +CREATE TABLE "resource" ( + "id" TEXT NOT NULL, + "title" TEXT, + "description" TEXT, + "type" TEXT, + "fileId" TEXT, + "url" TEXT, + "meta" JSONB, + "status" TEXT, + "created_at" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP, + "updated_at" TIMESTAMP(3), + "created_by" TEXT, + "updated_by" TEXT, + "deleted_at" TIMESTAMP(3), + "is_public" BOOLEAN DEFAULT true, + + CONSTRAINT "resource_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "resource_fileId_key" ON "resource"("fileId"); + +-- CreateIndex +CREATE INDEX "resource_type_idx" ON "resource"("type"); + +-- CreateIndex +CREATE INDEX "resource_created_at_idx" ON "resource"("created_at"); diff --git a/packages/db/prisma/migrations/20250604044608_y/migration.sql b/packages/db/prisma/migrations/20250604044608_y/migration.sql new file mode 100644 index 0000000..0c3969b --- /dev/null +++ b/packages/db/prisma/migrations/20250604044608_y/migration.sql @@ -0,0 +1,14 @@ +/* + Warnings: + + - You are about to drop the column `is_public` on the `resource` table. All the data in the column will be lost. + - Added the required column `storage_type` to the `resource` table without a default value. This is not possible if the table is not empty. + - Made the column `title` on table `resource` required. This step will fail if there are existing NULL values in that column. + - Made the column `fileId` on table `resource` required. This step will fail if there are existing NULL values in that column. + +*/ +-- AlterTable +ALTER TABLE "resource" DROP COLUMN "is_public", +ADD COLUMN "storage_type" TEXT NOT NULL, +ALTER COLUMN "title" SET NOT NULL, +ALTER COLUMN "fileId" SET NOT NULL; diff --git a/packages/db/prisma/migrations/20250604044641_y/migration.sql b/packages/db/prisma/migrations/20250604044641_y/migration.sql new file mode 100644 index 0000000..833d422 --- /dev/null +++ b/packages/db/prisma/migrations/20250604044641_y/migration.sql @@ -0,0 +1,22 @@ +/* + Warnings: + + - Made the column `description` on table `resource` required. This step will fail if there are existing NULL values in that column. + - Made the column `type` on table `resource` required. This step will fail if there are existing NULL values in that column. + - Made the column `meta` on table `resource` required. This step will fail if there are existing NULL values in that column. + - Made the column `created_at` on table `resource` required. This step will fail if there are existing NULL values in that column. + - Made the column `updated_at` on table `resource` required. This step will fail if there are existing NULL values in that column. + - Made the column `created_by` on table `resource` required. This step will fail if there are existing NULL values in that column. + - Made the column `updated_by` on table `resource` required. This step will fail if there are existing NULL values in that column. + - Made the column `deleted_at` on table `resource` required. This step will fail if there are existing NULL values in that column. + +*/ +-- AlterTable +ALTER TABLE "resource" ALTER COLUMN "description" SET NOT NULL, +ALTER COLUMN "type" SET NOT NULL, +ALTER COLUMN "meta" SET NOT NULL, +ALTER COLUMN "created_at" SET NOT NULL, +ALTER COLUMN "updated_at" SET NOT NULL, +ALTER COLUMN "created_by" SET NOT NULL, +ALTER COLUMN "updated_by" SET NOT NULL, +ALTER COLUMN "deleted_at" SET NOT NULL; diff --git a/packages/db/prisma/migrations/20250604072756_y/migration.sql b/packages/db/prisma/migrations/20250604072756_y/migration.sql new file mode 100644 index 0000000..47ed39b --- /dev/null +++ b/packages/db/prisma/migrations/20250604072756_y/migration.sql @@ -0,0 +1,9 @@ +-- AlterTable +ALTER TABLE "resource" ADD COLUMN "is_public" BOOLEAN DEFAULT true, +ALTER COLUMN "description" DROP NOT NULL, +ALTER COLUMN "type" DROP NOT NULL, +ALTER COLUMN "meta" DROP NOT NULL, +ALTER COLUMN "created_by" DROP NOT NULL, +ALTER COLUMN "updated_by" DROP NOT NULL, +ALTER COLUMN "deleted_at" DROP NOT NULL, +ALTER COLUMN "storage_type" DROP NOT NULL; diff --git a/packages/db/prisma/schema.prisma b/packages/db/prisma/schema.prisma index 994debd..9476916 100755 --- a/packages/db/prisma/schema.prisma +++ b/packages/db/prisma/schema.prisma @@ -402,3 +402,25 @@ enum LineageStatus { ACTIVE ARCHIVED } +model Resource { + id String @id @default(cuid()) @map("id") + title String @map("title") + description String? @map("description") + type String? @map("type") + fileId String @unique + url String? + meta Json? @map("meta") + status String? + createdAt DateTime @default(now()) @map("created_at") + updatedAt DateTime @updatedAt @map("updated_at") + createdBy String? @map("created_by") + updatedBy String? @map("updated_by") + deletedAt DateTime? @map("deleted_at") + isPublic Boolean? @default(true) @map("is_public") + storageType String? @map("storage_type") + + // 索引 + @@index([type]) + @@index([createdAt]) + @@map("resource") +} \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 974e930..60ccb76 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -515,61 +515,6 @@ importers: specifier: ^5.0.0 version: 5.8.3 - packages/tus: - dependencies: - '@aws-sdk/client-s3': - specifier: ^3.723.0 - version: 3.817.0 - '@shopify/semaphore': - specifier: ^3.1.0 - version: 3.1.0 - debug: - specifier: ^4.4.0 - version: 4.4.1 - lodash.throttle: - specifier: ^4.1.1 - version: 4.1.1 - multistream: - specifier: ^4.1.0 - version: 4.1.0 - devDependencies: - '@redis/client': - specifier: ^1.6.0 - version: 1.6.1 - '@types/debug': - specifier: ^4.1.12 - version: 4.1.12 - '@types/lodash.throttle': - specifier: ^4.1.9 - version: 4.1.9 - '@types/multistream': - specifier: ^4.1.3 - version: 4.1.3 - '@types/node': - specifier: ^20.3.1 - version: 20.17.50 - concurrently: - specifier: ^8.0.0 - version: 8.2.2 - ioredis: - specifier: ^5.4.1 - version: 5.4.1 - rimraf: - specifier: ^6.0.1 - version: 6.0.1 - should: - specifier: ^13.2.3 - version: 13.2.3 - ts-node: - specifier: ^10.9.1 - version: 10.9.2(@swc/core@1.11.29(@swc/helpers@0.5.17))(@types/node@20.17.50)(typescript@5.8.3) - tsup: - specifier: ^8.3.5 - version: 8.5.0(@swc/core@1.11.29(@swc/helpers@0.5.17))(jiti@2.4.2)(postcss@8.5.3)(tsx@4.19.4)(typescript@5.8.3)(yaml@2.8.0) - typescript: - specifier: ^5.5.4 - version: 5.8.3 - packages/typescript-config: {} packages/ui: @@ -5117,24 +5062,6 @@ packages: resolution: {integrity: sha512-AzqKpGKjrj7EM6rKVQEPpB288oCfnrEIuyoT9cyF4nmGa7V8Zk6f7RRqYisX8X9m+Q7bd632aZW4ky7EhbQztA==} engines: {node: '>= 0.4'} - should-equal@2.0.0: - resolution: {integrity: sha512-ZP36TMrK9euEuWQYBig9W55WPC7uo37qzAEmbjHz4gfyuXrEUgF8cUvQVO+w+d3OMfPvSRQJ22lSm8MQJ43LTA==} - - should-format@3.0.3: - resolution: {integrity: sha512-hZ58adtulAk0gKtua7QxevgUaXTTXxIi8t41L3zo9AHvjXO1/7sdLECuHeIN2SRtYXpNkmhoUP2pdeWgricQ+Q==} - - should-type-adaptors@1.1.0: - resolution: {integrity: sha512-JA4hdoLnN+kebEp2Vs8eBe9g7uy0zbRo+RMcU0EsNy+R+k049Ki+N5tT5Jagst2g7EAja+euFuoXFCa8vIklfA==} - - should-type@1.4.0: - resolution: {integrity: sha512-MdAsTu3n25yDbIe1NeN69G4n6mUnJGtSJHygX3+oN0ZbO3DTiATnf7XnYJdGT42JCXurTb1JI0qOBR65shvhPQ==} - - should-util@1.0.1: - resolution: {integrity: sha512-oXF8tfxx5cDk8r2kYqlkUJzZpDBqVY/II2WhvU0n9Y3XYvAYRmeaf1PvvIvTgPnv4KJ+ES5M0PyDq5Jp+Ygy2g==} - - should@13.2.3: - resolution: {integrity: sha512-ggLesLtu2xp+ZxI+ysJTmNjh2U0TsC+rQ/pfED9bUZZ4DKefP27D+7YJVVTvKsmjLpIi9jAa7itwDGkDDmt1GQ==} - side-channel-list@1.0.0: resolution: {integrity: sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==} engines: {node: '>= 0.4'} @@ -10984,32 +10911,6 @@ snapshots: shell-quote@1.8.2: {} - should-equal@2.0.0: - dependencies: - should-type: 1.4.0 - - should-format@3.0.3: - dependencies: - should-type: 1.4.0 - should-type-adaptors: 1.1.0 - - should-type-adaptors@1.1.0: - dependencies: - should-type: 1.4.0 - should-util: 1.0.1 - - should-type@1.4.0: {} - - should-util@1.0.1: {} - - should@13.2.3: - dependencies: - should-equal: 2.0.0 - should-format: 3.0.3 - should-type: 1.4.0 - should-type-adaptors: 1.1.0 - should-util: 1.0.1 - side-channel-list@1.0.0: dependencies: es-errors: 1.3.0