|
1 | 1 | import fs from 'node:fs'; |
2 | 2 | import path from 'node:path'; |
3 | 3 | import { CliError } from '../cli-error'; |
4 | | -import { execPackage } from '../utils/exec-utils'; |
| 4 | +import { execPrisma } from '../utils/exec-utils'; |
5 | 5 | import { generateTempPrismaSchema, getSchemaFile } from './action-utils'; |
6 | 6 |
|
7 | 7 | type CommonOptions = { |
@@ -64,69 +64,65 @@ export async function run(command: string, options: CommonOptions) { |
64 | 64 | } |
65 | 65 | } |
66 | 66 |
|
67 | | -async function runDev(prismaSchemaFile: string, options: DevOptions) { |
| 67 | +function runDev(prismaSchemaFile: string, options: DevOptions) { |
68 | 68 | try { |
69 | 69 | const cmd = [ |
70 | | - 'prisma migrate dev', |
| 70 | + 'migrate dev', |
71 | 71 | ` --schema "${prismaSchemaFile}"`, |
72 | 72 | ' --skip-generate', |
73 | | - options.name ? ` --name ${options.name}` : '', |
| 73 | + options.name ? ` --name "${options.name}"` : '', |
74 | 74 | options.createOnly ? ' --create-only' : '', |
75 | 75 | ].join(''); |
76 | | - |
77 | | - await execPackage(cmd); |
| 76 | + execPrisma(cmd); |
78 | 77 | } catch (err) { |
79 | 78 | handleSubProcessError(err); |
80 | 79 | } |
81 | 80 | } |
82 | 81 |
|
83 | | -async function runReset(prismaSchemaFile: string, options: ResetOptions) { |
| 82 | +function runReset(prismaSchemaFile: string, options: ResetOptions) { |
84 | 83 | try { |
85 | 84 | const cmd = [ |
86 | | - 'prisma migrate reset', |
| 85 | + 'migrate reset', |
87 | 86 | ` --schema "${prismaSchemaFile}"`, |
88 | 87 | ' --skip-generate', |
89 | 88 | options.force ? ' --force' : '', |
90 | 89 | ].join(''); |
91 | | - |
92 | | - await execPackage(cmd); |
| 90 | + execPrisma(cmd); |
93 | 91 | } catch (err) { |
94 | 92 | handleSubProcessError(err); |
95 | 93 | } |
96 | 94 | } |
97 | 95 |
|
98 | | -async function runDeploy(prismaSchemaFile: string, _options: DeployOptions) { |
| 96 | +function runDeploy(prismaSchemaFile: string, _options: DeployOptions) { |
99 | 97 | try { |
100 | | - const cmd = ['prisma migrate deploy', ` --schema "${prismaSchemaFile}"`].join(''); |
101 | | - |
102 | | - await execPackage(cmd); |
| 98 | + const cmd = ['migrate deploy', ` --schema "${prismaSchemaFile}"`].join(''); |
| 99 | + execPrisma(cmd); |
103 | 100 | } catch (err) { |
104 | 101 | handleSubProcessError(err); |
105 | 102 | } |
106 | 103 | } |
107 | 104 |
|
108 | | -async function runStatus(prismaSchemaFile: string, _options: StatusOptions) { |
| 105 | +function runStatus(prismaSchemaFile: string, _options: StatusOptions) { |
109 | 106 | try { |
110 | | - await execPackage(`prisma migrate status --schema "${prismaSchemaFile}"`); |
| 107 | + execPrisma(`migrate status --schema "${prismaSchemaFile}"`); |
111 | 108 | } catch (err) { |
112 | 109 | handleSubProcessError(err); |
113 | 110 | } |
114 | 111 | } |
115 | 112 |
|
116 | | -async function runResolve(prismaSchemaFile: string, options: ResolveOptions) { |
| 113 | +function runResolve(prismaSchemaFile: string, options: ResolveOptions) { |
117 | 114 | if (!options.applied && !options.rolledBack) { |
118 | 115 | throw new CliError('Either --applied or --rolled-back option must be provided'); |
119 | 116 | } |
120 | 117 |
|
121 | 118 | try { |
122 | 119 | const cmd = [ |
123 | | - 'prisma migrate resolve', |
| 120 | + 'migrate resolve', |
124 | 121 | ` --schema "${prismaSchemaFile}"`, |
125 | | - options.applied ? ` --applied ${options.applied}` : '', |
126 | | - options.rolledBack ? ` --rolled-back ${options.rolledBack}` : '', |
| 122 | + options.applied ? ` --applied "${options.applied}"` : '', |
| 123 | + options.rolledBack ? ` --rolled-back "${options.rolledBack}"` : '', |
127 | 124 | ].join(''); |
128 | | - |
129 | | - await execPackage(cmd); |
| 125 | + execPrisma(cmd); |
130 | 126 | } catch (err) { |
131 | 127 | handleSubProcessError(err); |
132 | 128 | } |
|
0 commit comments