MCPcopy
hub / github.com/prisma/prisma / DbPull

Class DbPull

packages/migrate/src/commands/DbPull.ts:39–324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37const debug = Debug('prisma:db:pull')
38
39export class DbPull implements Command {
40 public static new(): DbPull {
41 return new DbPull()
42 }
43
44 private static help = format(`
45Pull the state from the database to the Prisma schema using introspection
46
47${bold('Usage')}
48
49 ${dim('$')} prisma db pull [flags/options]
50
51 The datasource URL configuration is read from the Prisma config file (e.g., ${italic('prisma.config.ts')}).
52
53${bold('Flags')}
54
55 -h, --help Display this help message
56 --force Ignore current Prisma schema file
57 --print Print the introspected Prisma schema to stdout
58
59${bold('Options')}
60
61 --config Custom path to your Prisma config file
62 --schema Custom path to your Prisma schema
63 --url Override the datasource URL from the Prisma config file
64 --composite-type-depth Specify the depth for introspecting composite types (e.g. Embedded Documents in MongoDB)
65 Number, default is -1 for infinite depth, 0 = off
66 --schemas Specify the database schemas to introspect. This overrides the schemas defined in the datasource block of your Prisma schema.
67 --local-d1 Generate a Prisma schema from a local Cloudflare D1 database
68${bold('Examples')}
69
70With an existing Prisma schema
71 ${dim('$')} prisma db pull
72
73Or specify a Prisma schema path
74 ${dim('$')} prisma db pull --schema=./schema.prisma
75
76Instead of saving the result to the filesystem, you can also print it to stdout
77 ${dim('$')} prisma db pull --print
78
79Overwrite the current schema with the introspected schema instead of enriching it
80 ${dim('$')} prisma db pull --force
81
82Set composite types introspection depth to 2 levels
83 ${dim('$')} prisma db pull --composite-type-depth=2
84
85`)
86
87 public async parse(
88 argv: string[],
89 config: PrismaConfigInternal,
90 baseDir: string = process.cwd(),
91 ): Promise<string | Error> {
92 const args = arg(argv, {
93 '--help': Boolean,
94 '-h': '--help',
95 '--print': Boolean,
96 '--schema': String,

Callers

nothing calls this directly

Calls 1

formatFunction · 0.90

Tested by

no test coverage detected