@factor-wise/prisma-schema

中文文档
3.0.21发布于 2026/11/12ISCTypeScriptCommonJS近 30 天下载 2679

Shared Prisma schema and generated client for Factor Wise projects

原始使用文档
文档目录6 节
  1. 📚 Table of Contents
  2. 📌 Project Overview
  3. 🛠️ Tech Stack
  4. 📂 Project Structure
  5. 🚀 Getting Started
  6. Production database changes

🏗️ Factorwise Project — Prisma Schema

Welcome to the Factorwise Project Schema Repository.
This repository contains the official Prisma schema, migrations, and related setup for the Factorwise backend system. It is designed specifically for Factorwise and must not be reused or modified for any other projects.

⚠️ Important:
This is a private schema. Usage of this schema outside of the Factorwise environment is strictly prohibited.


📚 Table of Contents


📌 Project Overview

This schema serves as the single source of truth for the Factorwise backend database.
It defines the models, relations, enums, and constraints required for all services interacting with the Factorwise data layer.

  • ✅ Centralized schema for all DB models
  • ✅ Managed migrations with Prisma
  • ✅ Enums and mappings aligned with business logic
  • ✅ Designed for multi-tenant setups using Prisma Client

🛠️ Tech Stack

  • Prisma ORM — Database modeling & migrations
  • TypeScript — Type-safe schema and client code
  • MySQL — Primary database engine
  • Node.js / NestJS — For backend integration

📂 Project Structure

  • prisma/schema.prisma → Core database models and enums for Factorwise.
  • migrations/ → Auto-generated by Prisma when pushing changes.
  • package.json → Used for managing versioning and publishing the schema internally.
  • README.md → Project documentation.

🚀 Getting Started


npm install


npx prisma generate


npm run db:plan -- describe_your_change

Production database changes

Do not run prisma db push against production. This database is large and has historical schema drift, so db push can unexpectedly alter unrelated tables.

Use one focused, reviewed SQL change instead:

  1. Commit the current schema as the baseline.

  2. Edit prisma/schema.prisma with one logical change.

  3. Generate SQL containing only that edit:

    npm run db:plan -- add_customer_key
    
  4. Review the generated file in prisma/changes/. The command reports common operations that scan, lock, or rebuild populated tables.

  5. Test the SQL on a production-sized staging database. For an index or foreign key on a large table, use an online schema-change tool and schedule it during low traffic; Prisma cannot make the MySQL table operation instant.

  6. Apply the exact reviewed file:

    npm run db:check -- prisma/changes/<file>.sql
    npm run db:apply -- prisma/changes/<file>.sql
    npm run generate
    

    The command asks you to type APPLY before connecting to the configured database. A file containing DROP TABLE or DROP COLUMN asks for a second DELETE confirmation. Non-interactive CI can use --confirm-production and, for destructive changes, --confirm-data-loss.

  7. Commit schema.prisma and the SQL change file together.

db:plan compares the working schema to the committed schema rather than the live database. This prevents old, unrelated database drift from being included in a new production change. The db:apply command uses the database configured by DATABASE_URL; verify that target before confirming production execution.


Built and maintained with ❤️ by the Factorwise Development Team.

版本与发布记录

@factor-wise/prisma-schema 共发布 183 个版本,首次发布于 2025/09/27;过去 12 个月发布了 157 个版本。

版本发布日期距今
3.0.21latest2026/11/122 天前
3.0.202026/11/058 天前
3.0.192026/10/3014 天前
3.0.182026/10/3014 天前
3.0.172026/10/3014 天前
3.0.162026/10/3015 天前

关于 @factor-wise/prisma-schema 的常见问题

@factor-wise/prisma-schema 是什么?

Shared Prisma schema and generated client for Factor Wise projects

如何安装 @factor-wise/prisma-schema?

在项目目录运行 npm install @factor-wise/prisma-schema,或使用 pnpm add / yarn add / bun add。

@factor-wise/prisma-schema 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@factor-wise/prisma-schema 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@factor-wise/prisma-schema 可以商用吗?

@factor-wise/prisma-schema 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@factor-wise/prisma-schema 的下载量有多少?

根据 npm 官方下载统计,@factor-wise/prisma-schema 在 2026/10/14 – 2026/11/12 这 30 天内被下载 2,679 次,日均约 89 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@factor-wise/prisma-schema 还在维护吗?

最新版本 3.0.21 发布于 2026/11/12(2 天前);至今共发布 183 个版本,其中过去 12 个月发布了 157 个;首次发布于 2025/09/27。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。