You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// First, error out if we aren't making all changes
96
-
if(migrationMode==="none"&&incompatible){
97
-
thrownewFirebaseError("Command aborted.");
98
-
}
99
-
100
94
letdiffs: Diff[]=[];
101
95
if(incompatible){
102
96
diffs=awaithandleIncompatibleSchemaError({
@@ -205,44 +199,51 @@ async function handleIncompatibleSchemaError(args: {
205
199
asyncfunctionpromptForSchemaMigration(
206
200
options: Options,
207
201
databaseName: string,
208
-
err: IncompatibleSqlSchemaError,
209
-
allowNonInteractiveMigration: boolean,
210
-
): Promise<"none"|"safe"|"all">{
202
+
err: IncompatibleSqlSchemaError|undefined,
203
+
validateOnly: boolean,
204
+
): Promise<"none"|"all">{
205
+
if(!err){
206
+
return"none";
207
+
}
211
208
displaySchemaChanges(err);
212
209
if(!options.nonInteractive){
213
-
// Always prompt in interactive mode. Destructive migrations are too potentially dangerous to not prompt for with --force
210
+
if(validateOnly&&options.force){
211
+
// `firebase dataconnect:sql:migrate --force` performs all migrations
212
+
return"all";
213
+
}
214
+
// `firebase deploy` and `firebase dataconnect:sql:migrate` always prompt for any SQL migration changes.
215
+
// Destructive migrations are too potentially dangerous to not prompt for with --force
214
216
constchoices=err.destructive
215
217
? [
216
218
{name: "Execute all changes (including destructive changes)",value: "all"},
217
219
{name: "Abort changes",value: "none"},
218
220
]
219
221
: [
220
-
{name: "Execute changes",value: "safe"},
222
+
{name: "Execute changes",value: "all"},
221
223
{name: "Abort changes",value: "none"},
222
224
];
223
225
returnawaitpromptOnce({
224
226
message: `Would you like to execute these changes against ${databaseName}?`,
225
227
type: "list",
226
228
choices,
227
229
});
228
-
}elseif(!allowNonInteractiveMigration){
229
-
// `deploy --nonInteractive` performs no migrations
230
-
logger.error(
231
-
"Your database schema is incompatible with your Data Connect schema. Run `firebase dataconnect:sql:migrate` to migrate your database schema",
230
+
}
231
+
if(!validateOnly){
232
+
// `firebase deploy --nonInteractive` performs no migrations
233
+
thrownewFirebaseError(
234
+
"Command aborted. Your database schema is incompatible with your Data Connect schema. Run `firebase dataconnect:sql:migrate` to migrate your database schema",
232
235
);
233
-
return"none";
234
236
}elseif(options.force){
235
-
// `dataconnect:sql:migrate --nonInteractive --force` performs all migrations
237
+
// `dataconnect:sql:migrate --nonInteractive --force` performs all migrations.
236
238
return"all";
237
239
}elseif(!err.destructive){
238
-
// `dataconnect:sql:migrate --nonInteractive` performs only safe migrations
239
-
return"safe";
240
+
// `dataconnect:sql:migrate --nonInteractive` performs only non-destructive migrations.
241
+
return"all";
240
242
}else{
241
243
// `dataconnect:sql:migrate --nonInteractive` errors out if there are destructive migrations
242
-
logger.error(
243
-
"This schema migration includes potentially destructive changes. If you'd like to execute it anyway, rerun this command with --force",
244
+
thrownewFirebaseError(
245
+
"Command aborted. This schema migration includes potentially destructive changes. If you'd like to execute it anyway, rerun this command with --force",
0 commit comments