@patricio0312rev/skillset 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/LICENSE +21 -0
- package/README.md +176 -0
- package/bin/cli.js +37 -0
- package/package.json +55 -0
- package/src/commands/init.js +301 -0
- package/src/index.js +168 -0
- package/src/lib/config.js +200 -0
- package/src/lib/generator.js +166 -0
- package/src/utils/display.js +95 -0
- package/src/utils/readme.js +196 -0
- package/src/utils/tool-specific.js +233 -0
- package/templates/ai-engineering/agent-orchestration-planner/ SKILL.md +266 -0
- package/templates/ai-engineering/cost-latency-optimizer/ SKILL.md +270 -0
- package/templates/ai-engineering/doc-to-vector-dataset-generator/ SKILL.md +239 -0
- package/templates/ai-engineering/evaluation-harness/ SKILL.md +219 -0
- package/templates/ai-engineering/guardrails-safety-filter-builder/ SKILL.md +226 -0
- package/templates/ai-engineering/llm-debugger/ SKILL.md +283 -0
- package/templates/ai-engineering/prompt-regression-tester/ SKILL.md +216 -0
- package/templates/ai-engineering/prompt-template-builder/ SKILL.md +393 -0
- package/templates/ai-engineering/rag-pipeline-builder/ SKILL.md +244 -0
- package/templates/ai-engineering/tool-function-schema-designer/ SKILL.md +219 -0
- package/templates/architecture/adr-writer/ SKILL.md +250 -0
- package/templates/architecture/api-versioning-deprecation-planner/ SKILL.md +331 -0
- package/templates/architecture/domain-model-boundaries-mapper/ SKILL.md +300 -0
- package/templates/architecture/migration-planner/ SKILL.md +376 -0
- package/templates/architecture/performance-budget-setter/ SKILL.md +318 -0
- package/templates/architecture/reliability-strategy-builder/ SKILL.md +286 -0
- package/templates/architecture/rfc-generator/ SKILL.md +362 -0
- package/templates/architecture/scalability-playbook/ SKILL.md +279 -0
- package/templates/architecture/system-design-generator/ SKILL.md +339 -0
- package/templates/architecture/tech-debt-prioritizer/ SKILL.md +329 -0
- package/templates/backend/api-contract-normalizer/ SKILL.md +487 -0
- package/templates/backend/api-endpoint-generator/ SKILL.md +415 -0
- package/templates/backend/auth-module-builder/ SKILL.md +99 -0
- package/templates/backend/background-jobs-designer/ SKILL.md +166 -0
- package/templates/backend/caching-strategist/ SKILL.md +190 -0
- package/templates/backend/error-handling-standardizer/ SKILL.md +174 -0
- package/templates/backend/rate-limiting-abuse-protection/ SKILL.md +147 -0
- package/templates/backend/rbac-permissions-builder/ SKILL.md +158 -0
- package/templates/backend/service-layer-extractor/ SKILL.md +269 -0
- package/templates/backend/webhook-receiver-hardener/ SKILL.md +211 -0
- package/templates/ci-cd/artifact-sbom-publisher/ SKILL.md +236 -0
- package/templates/ci-cd/caching-strategy-optimizer/ SKILL.md +195 -0
- package/templates/ci-cd/deployment-checklist-generator/ SKILL.md +381 -0
- package/templates/ci-cd/github-actions-pipeline-creator/ SKILL.md +348 -0
- package/templates/ci-cd/monorepo-ci-optimizer/ SKILL.md +298 -0
- package/templates/ci-cd/preview-environments-builder/ SKILL.md +187 -0
- package/templates/ci-cd/quality-gates-enforcer/ SKILL.md +342 -0
- package/templates/ci-cd/release-automation-builder/ SKILL.md +281 -0
- package/templates/ci-cd/rollback-workflow-builder/ SKILL.md +372 -0
- package/templates/ci-cd/secrets-env-manager/ SKILL.md +242 -0
- package/templates/db-management/backup-restore-runbook-generator/ SKILL.md +505 -0
- package/templates/db-management/data-integrity-auditor/ SKILL.md +505 -0
- package/templates/db-management/data-retention-archiving-planner/ SKILL.md +430 -0
- package/templates/db-management/data-seeding-fixtures-builder/ SKILL.md +375 -0
- package/templates/db-management/db-performance-watchlist/ SKILL.md +425 -0
- package/templates/db-management/etl-sync-job-builder/ SKILL.md +457 -0
- package/templates/db-management/multi-tenant-safety-checker/ SKILL.md +398 -0
- package/templates/db-management/prisma-migration-assistant/ SKILL.md +379 -0
- package/templates/db-management/schema-consistency-checker/ SKILL.md +440 -0
- package/templates/db-management/sql-query-optimizer/ SKILL.md +324 -0
- package/templates/foundation/changelog-writer/ SKILL.md +431 -0
- package/templates/foundation/code-formatter-installer/ SKILL.md +320 -0
- package/templates/foundation/codebase-summarizer/ SKILL.md +360 -0
- package/templates/foundation/dependency-doctor/ SKILL.md +163 -0
- package/templates/foundation/dev-environment-bootstrapper/ SKILL.md +259 -0
- package/templates/foundation/dev-onboarding-builder/ SKILL.md +556 -0
- package/templates/foundation/docs-starter-kit/ SKILL.md +574 -0
- package/templates/foundation/explaining-code/SKILL.md +13 -0
- package/templates/foundation/git-hygiene-enforcer/ SKILL.md +455 -0
- package/templates/foundation/project-scaffolder/ SKILL.md +65 -0
- package/templates/foundation/project-scaffolder/references/templates.md +126 -0
- package/templates/foundation/repo-structure-linter/ SKILL.md +0 -0
- package/templates/foundation/repo-structure-linter/references/conventions.md +98 -0
- package/templates/frontend/animation-micro-interaction-pack/ SKILL.md +41 -0
- package/templates/frontend/component-scaffold-generator/ SKILL.md +562 -0
- package/templates/frontend/design-to-component-translator/ SKILL.md +547 -0
- package/templates/frontend/form-wizard-builder/ SKILL.md +553 -0
- package/templates/frontend/frontend-refactor-planner/ SKILL.md +37 -0
- package/templates/frontend/i18n-frontend-implementer/ SKILL.md +44 -0
- package/templates/frontend/modal-drawer-system/ SKILL.md +377 -0
- package/templates/frontend/page-layout-builder/ SKILL.md +630 -0
- package/templates/frontend/state-ux-flow-builder/ SKILL.md +23 -0
- package/templates/frontend/table-builder/ SKILL.md +350 -0
- package/templates/performance/alerting-dashboard-builder/ SKILL.md +162 -0
- package/templates/performance/backend-latency-profiler-helper/ SKILL.md +108 -0
- package/templates/performance/caching-cdn-strategy-planner/ SKILL.md +150 -0
- package/templates/performance/capacity-planning-helper/ SKILL.md +242 -0
- package/templates/performance/core-web-vitals-tuner/ SKILL.md +126 -0
- package/templates/performance/incident-runbook-generator/ SKILL.md +162 -0
- package/templates/performance/load-test-scenario-builder/ SKILL.md +256 -0
- package/templates/performance/observability-setup/ SKILL.md +232 -0
- package/templates/performance/postmortem-writer/ SKILL.md +203 -0
- package/templates/performance/structured-logging-standardizer/ SKILL.md +122 -0
- package/templates/security/auth-security-reviewer/ SKILL.md +428 -0
- package/templates/security/dependency-vulnerability-triage/ SKILL.md +495 -0
- package/templates/security/input-validation-sanitization-auditor/ SKILL.md +76 -0
- package/templates/security/pii-redaction-logging-policy-builder/ SKILL.md +65 -0
- package/templates/security/rbac-policy-tester/ SKILL.md +80 -0
- package/templates/security/secrets-scanner/ SKILL.md +462 -0
- package/templates/security/secure-headers-csp-builder/ SKILL.md +404 -0
- package/templates/security/security-incident-playbook-generator/ SKILL.md +76 -0
- package/templates/security/security-pr-checklist-skill/ SKILL.md +62 -0
- package/templates/security/threat-model-generator/ SKILL.md +394 -0
- package/templates/testing/contract-testing-builder/ SKILL.md +492 -0
- package/templates/testing/coverage-strategist/ SKILL.md +436 -0
- package/templates/testing/e2e-test-builder/ SKILL.md +382 -0
- package/templates/testing/flaky-test-detective/ SKILL.md +416 -0
- package/templates/testing/integration-test-builder/ SKILL.md +525 -0
- package/templates/testing/mocking-assistant/ SKILL.md +383 -0
- package/templates/testing/snapshot-test-refactorer/ SKILL.md +375 -0
- package/templates/testing/test-data-factory-builder/ SKILL.md +449 -0
- package/templates/testing/test-reporting-triage-skill/ SKILL.md +469 -0
- package/templates/testing/unit-test-generator/ SKILL.md +548 -0
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: data-seeding-fixtures-builder
|
|
3
|
+
description: Generates deterministic seed data for development and testing with factory functions, realistic fixtures, and database reset scripts. Use for "data seeding", "test fixtures", "database seeding", or "mock data generation".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Data Seeding & Fixtures Builder
|
|
7
|
+
|
|
8
|
+
Generate realistic, deterministic seed data for development and testing.
|
|
9
|
+
|
|
10
|
+
## Seed Data Strategy
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
// prisma/seed.ts
|
|
14
|
+
import { PrismaClient } from "@prisma/client";
|
|
15
|
+
import { faker } from "@faker-js/faker";
|
|
16
|
+
|
|
17
|
+
const prisma = new PrismaClient();
|
|
18
|
+
|
|
19
|
+
async function main() {
|
|
20
|
+
console.log("🌱 Seeding database...");
|
|
21
|
+
|
|
22
|
+
// Clear existing data
|
|
23
|
+
await prisma.order.deleteMany();
|
|
24
|
+
await prisma.user.deleteMany();
|
|
25
|
+
|
|
26
|
+
// Seed users
|
|
27
|
+
const users = await seedUsers(10);
|
|
28
|
+
console.log(`✅ Created ${users.length} users`);
|
|
29
|
+
|
|
30
|
+
// Seed orders
|
|
31
|
+
const orders = await seedOrders(users, 50);
|
|
32
|
+
console.log(`✅ Created ${orders.length} orders`);
|
|
33
|
+
|
|
34
|
+
console.log("✅ Seeding complete!");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
main()
|
|
38
|
+
.catch((e) => {
|
|
39
|
+
console.error(e);
|
|
40
|
+
process.exit(1);
|
|
41
|
+
})
|
|
42
|
+
.finally(async () => {
|
|
43
|
+
await prisma.$disconnect();
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Factory Functions
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
// factories/user.factory.ts
|
|
51
|
+
import { faker } from "@faker-js/faker";
|
|
52
|
+
import { PrismaClient, User } from "@prisma/client";
|
|
53
|
+
|
|
54
|
+
const prisma = new PrismaClient();
|
|
55
|
+
|
|
56
|
+
export interface UserFactoryOptions {
|
|
57
|
+
email?: string;
|
|
58
|
+
name?: string;
|
|
59
|
+
role?: "USER" | "ADMIN";
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export class UserFactory {
|
|
63
|
+
static async create(options: UserFactoryOptions = {}): Promise<User> {
|
|
64
|
+
return prisma.user.create({
|
|
65
|
+
data: {
|
|
66
|
+
email: options.email || faker.internet.email(),
|
|
67
|
+
name: options.name || faker.person.fullName(),
|
|
68
|
+
role: options.role || "USER",
|
|
69
|
+
createdAt: faker.date.past(),
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
static async createMany(
|
|
75
|
+
count: number,
|
|
76
|
+
options: UserFactoryOptions = {}
|
|
77
|
+
): Promise<User[]> {
|
|
78
|
+
return Promise.all(
|
|
79
|
+
Array.from({ length: count }, () => this.create(options))
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
static async createAdmin(): Promise<User> {
|
|
84
|
+
return this.create({ role: "ADMIN" });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Usage:
|
|
89
|
+
// const user = await UserFactory.create();
|
|
90
|
+
// const admin = await UserFactory.createAdmin();
|
|
91
|
+
// const users = await UserFactory.createMany(10);
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Realistic Fixtures
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
// fixtures/products.ts
|
|
98
|
+
import { Product } from "@prisma/client";
|
|
99
|
+
|
|
100
|
+
export const PRODUCT_FIXTURES: Omit<
|
|
101
|
+
Product,
|
|
102
|
+
"id" | "createdAt" | "updatedAt"
|
|
103
|
+
>[] = [
|
|
104
|
+
{
|
|
105
|
+
name: 'MacBook Pro 16"',
|
|
106
|
+
description: "Powerful laptop for developers",
|
|
107
|
+
price: 2499.99,
|
|
108
|
+
stock: 50,
|
|
109
|
+
category: "Electronics",
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
name: "iPhone 15 Pro",
|
|
113
|
+
description: "Latest flagship smartphone",
|
|
114
|
+
price: 999.99,
|
|
115
|
+
stock: 100,
|
|
116
|
+
category: "Electronics",
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: "AirPods Pro",
|
|
120
|
+
description: "Wireless earbuds with noise cancellation",
|
|
121
|
+
price: 249.99,
|
|
122
|
+
stock: 200,
|
|
123
|
+
category: "Electronics",
|
|
124
|
+
},
|
|
125
|
+
];
|
|
126
|
+
|
|
127
|
+
// Seed products
|
|
128
|
+
async function seedProducts() {
|
|
129
|
+
return Promise.all(
|
|
130
|
+
PRODUCT_FIXTURES.map((product) => prisma.product.create({ data: product }))
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Deterministic Seeding
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
// Use fixed seed for reproducibility
|
|
139
|
+
import { faker } from "@faker-js/faker";
|
|
140
|
+
|
|
141
|
+
// Set seed for deterministic data
|
|
142
|
+
faker.seed(12345);
|
|
143
|
+
|
|
144
|
+
// Same data every time
|
|
145
|
+
const user1 = {
|
|
146
|
+
email: faker.internet.email(), // Always same email
|
|
147
|
+
name: faker.person.fullName(), // Always same name
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
// Reset for different test
|
|
151
|
+
faker.seed(67890);
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Relationship Building
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
// factories/order.factory.ts
|
|
158
|
+
export class OrderFactory {
|
|
159
|
+
static async create(userId: number): Promise<Order> {
|
|
160
|
+
const products = await prisma.product.findMany({ take: 3 });
|
|
161
|
+
|
|
162
|
+
const order = await prisma.order.create({
|
|
163
|
+
data: {
|
|
164
|
+
userId,
|
|
165
|
+
status: faker.helpers.arrayElement(["pending", "paid", "shipped"]),
|
|
166
|
+
total: faker.number.float({ min: 10, max: 1000, precision: 0.01 }),
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
// Create order items
|
|
171
|
+
await Promise.all(
|
|
172
|
+
products.map((product) =>
|
|
173
|
+
prisma.orderItem.create({
|
|
174
|
+
data: {
|
|
175
|
+
orderId: order.id,
|
|
176
|
+
productId: product.id,
|
|
177
|
+
quantity: faker.number.int({ min: 1, max: 5 }),
|
|
178
|
+
price: product.price,
|
|
179
|
+
},
|
|
180
|
+
})
|
|
181
|
+
)
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
return order;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
static async createForUser(user: User, count: number): Promise<Order[]> {
|
|
188
|
+
return Promise.all(
|
|
189
|
+
Array.from({ length: count }, () => this.create(user.id))
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Environment-Specific Seeds
|
|
196
|
+
|
|
197
|
+
```typescript
|
|
198
|
+
// seeds/development.ts
|
|
199
|
+
export async function seedDevelopment() {
|
|
200
|
+
// Development: Few records, easy to debug
|
|
201
|
+
const users = await UserFactory.createMany(5);
|
|
202
|
+
const products = await ProductFactory.createMany(10);
|
|
203
|
+
|
|
204
|
+
for (const user of users) {
|
|
205
|
+
await OrderFactory.createForUser(user, 2);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// seeds/staging.ts
|
|
210
|
+
export async function seedStaging() {
|
|
211
|
+
// Staging: Moderate data, realistic scenarios
|
|
212
|
+
const users = await UserFactory.createMany(50);
|
|
213
|
+
const products = await ProductFactory.createMany(100);
|
|
214
|
+
|
|
215
|
+
for (const user of users) {
|
|
216
|
+
await OrderFactory.createForUser(
|
|
217
|
+
user,
|
|
218
|
+
faker.number.int({ min: 1, max: 10 })
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// seeds/testing.ts
|
|
224
|
+
export async function seedTesting() {
|
|
225
|
+
// Testing: Minimal, predictable data
|
|
226
|
+
faker.seed(12345); // Deterministic
|
|
227
|
+
|
|
228
|
+
const user = await UserFactory.create({
|
|
229
|
+
email: "test@example.com",
|
|
230
|
+
name: "Test User",
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
const product = await ProductFactory.create({
|
|
234
|
+
name: "Test Product",
|
|
235
|
+
price: 99.99,
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
return { user, product };
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Main seed file
|
|
242
|
+
async function main() {
|
|
243
|
+
const env = process.env.NODE_ENV;
|
|
244
|
+
|
|
245
|
+
if (env === "development") {
|
|
246
|
+
await seedDevelopment();
|
|
247
|
+
} else if (env === "staging") {
|
|
248
|
+
await seedStaging();
|
|
249
|
+
} else if (env === "test") {
|
|
250
|
+
await seedTesting();
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## Database Reset Script
|
|
256
|
+
|
|
257
|
+
```typescript
|
|
258
|
+
// scripts/reset-db.ts
|
|
259
|
+
import { PrismaClient } from "@prisma/client";
|
|
260
|
+
|
|
261
|
+
const prisma = new PrismaClient();
|
|
262
|
+
|
|
263
|
+
async function resetDatabase() {
|
|
264
|
+
console.log("🗑️ Resetting database...");
|
|
265
|
+
|
|
266
|
+
// Disable foreign key checks (PostgreSQL)
|
|
267
|
+
await prisma.$executeRaw`SET session_replication_role = 'replica';`;
|
|
268
|
+
|
|
269
|
+
// Get all tables
|
|
270
|
+
const tables = await prisma.$queryRaw<{ tablename: string }[]>`
|
|
271
|
+
SELECT tablename FROM pg_tables WHERE schemaname = 'public';
|
|
272
|
+
`;
|
|
273
|
+
|
|
274
|
+
// Truncate all tables
|
|
275
|
+
for (const { tablename } of tables) {
|
|
276
|
+
if (tablename !== "_prisma_migrations") {
|
|
277
|
+
await prisma.$executeRawUnsafe(`TRUNCATE TABLE "${tablename}" CASCADE;`);
|
|
278
|
+
console.log(` Truncated ${tablename}`);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// Re-enable foreign key checks
|
|
283
|
+
await prisma.$executeRaw`SET session_replication_role = 'origin';`;
|
|
284
|
+
|
|
285
|
+
console.log("✅ Database reset complete");
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
resetDatabase()
|
|
289
|
+
.catch((e) => {
|
|
290
|
+
console.error(e);
|
|
291
|
+
process.exit(1);
|
|
292
|
+
})
|
|
293
|
+
.finally(() => prisma.$disconnect());
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
## Test Fixtures for E2E Tests
|
|
297
|
+
|
|
298
|
+
```typescript
|
|
299
|
+
// tests/fixtures/e2e.fixture.ts
|
|
300
|
+
import { test as base } from "@playwright/test";
|
|
301
|
+
import { UserFactory, ProductFactory } from "../factories";
|
|
302
|
+
|
|
303
|
+
type Fixtures = {
|
|
304
|
+
authenticatedUser: User;
|
|
305
|
+
products: Product[];
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
export const test = base.extend<Fixtures>({
|
|
309
|
+
authenticatedUser: async ({ page }, use) => {
|
|
310
|
+
// Create user
|
|
311
|
+
const user = await UserFactory.create();
|
|
312
|
+
|
|
313
|
+
// Login
|
|
314
|
+
await page.goto("/login");
|
|
315
|
+
await page.fill('[name="email"]', user.email);
|
|
316
|
+
await page.fill('[name="password"]', "password123");
|
|
317
|
+
await page.click('button[type="submit"]');
|
|
318
|
+
|
|
319
|
+
await use(user);
|
|
320
|
+
|
|
321
|
+
// Cleanup
|
|
322
|
+
await prisma.user.delete({ where: { id: user.id } });
|
|
323
|
+
},
|
|
324
|
+
|
|
325
|
+
products: async ({}, use) => {
|
|
326
|
+
const products = await ProductFactory.createMany(5);
|
|
327
|
+
await use(products);
|
|
328
|
+
|
|
329
|
+
// Cleanup
|
|
330
|
+
await prisma.product.deleteMany({
|
|
331
|
+
where: { id: { in: products.map((p) => p.id) } },
|
|
332
|
+
});
|
|
333
|
+
},
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
// Usage:
|
|
337
|
+
test("should add product to cart", async ({ authenticatedUser, products }) => {
|
|
338
|
+
// Test with pre-seeded data
|
|
339
|
+
});
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
## Package.json Scripts
|
|
343
|
+
|
|
344
|
+
```json
|
|
345
|
+
{
|
|
346
|
+
"scripts": {
|
|
347
|
+
"db:seed": "tsx prisma/seed.ts",
|
|
348
|
+
"db:seed:dev": "NODE_ENV=development tsx prisma/seed.ts",
|
|
349
|
+
"db:seed:staging": "NODE_ENV=staging tsx prisma/seed.ts",
|
|
350
|
+
"db:reset": "tsx scripts/reset-db.ts && npm run db:seed",
|
|
351
|
+
"db:reset:test": "tsx scripts/reset-db.ts && NODE_ENV=test tsx prisma/seed.ts"
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
## Best Practices
|
|
357
|
+
|
|
358
|
+
1. **Use factories**: Reusable data generation
|
|
359
|
+
2. **Deterministic in tests**: Fixed seed values
|
|
360
|
+
3. **Realistic fixtures**: Production-like data
|
|
361
|
+
4. **Environment-specific**: Different needs per environment
|
|
362
|
+
5. **Cleanup after tests**: Avoid pollution
|
|
363
|
+
6. **Relationship integrity**: Proper foreign keys
|
|
364
|
+
7. **Performance**: Batch inserts for large datasets
|
|
365
|
+
|
|
366
|
+
## Output Checklist
|
|
367
|
+
|
|
368
|
+
- [ ] Seed script created
|
|
369
|
+
- [ ] Factory functions for each model
|
|
370
|
+
- [ ] Realistic fixtures defined
|
|
371
|
+
- [ ] Deterministic seeding (tests)
|
|
372
|
+
- [ ] Relationship building logic
|
|
373
|
+
- [ ] Environment-specific seeds
|
|
374
|
+
- [ ] Database reset script
|
|
375
|
+
- [ ] E2E test fixtures
|