MCPcopy
hub / github.com/prisma/prisma / DbSeed

Class DbSeed

packages/migrate/src/commands/DbSeed.ts:8–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6import { executeSeedCommand } from '../utils/seed'
7
8export class DbSeed implements Command {
9 public static new(): DbSeed {
10 return new DbSeed()
11 }
12
13 private static help = format(`
14${process.platform === 'win32' ? '' : '🙌 '}Seed your database
15
16${bold('Usage')}
17
18 ${dim('$')} prisma db seed [options]
19
20${bold('Options')}
21
22 -h, --help Display this help message
23 --config Custom path to your Prisma config file
24
25${bold('Examples')}
26
27 Passing extra arguments to the seed command
28 ${dim('$')} prisma db seed -- --arg1 value1 --arg2 value2
29`)
30
31 public async parse(argv: string[], config: PrismaConfigInternal): Promise<string | Error> {
32 const args = arg(
33 argv,
34 {
35 '--help': Boolean,
36 '-h': '--help',
37 '--schema': String,
38 '--config': String,
39 '--telemetry-information': String,
40 },
41 false,
42 )
43
44 if (isError(args)) {
45 if (args instanceof ArgError && args.code === 'ARG_UNKNOWN_OPTION') {
46 throw new Error(`${args.message}
47Did you mean to pass these as arguments to your seed script? If so, add a -- separator before them:
48${dim('$')} prisma db seed -- --arg1 value1 --arg2 value2`)
49 }
50 return this.help(args.message)
51 }
52
53 if (args['--help']) {
54 return this.help()
55 }
56
57 const seedCommand = config.migrations?.seed
58
59 if (!seedCommand) {
60 return format(`⚠️ ${bold('No seed command configured')}
61
62To seed your database, add a ${bold('seed')} property to the ${bold('migrations')} section in your ${bold('Prisma config')} file.
63
64${bold('Example')}
65

Callers

nothing calls this directly

Calls 1

formatFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…