Skip to content

Commit

Permalink
warning for switch db
Browse files Browse the repository at this point in the history
  • Loading branch information
fredzqm committed May 10, 2024
1 parent d2e1172 commit 7b33e7e
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/dataconnect/schemaMigration.ts
Expand Up @@ -297,13 +297,22 @@ async function ensureServiceIsConnectedToCloudSql(
throw err;
}
}
if (
!currentSchema.primaryDatasource.postgresql ||
currentSchema.primaryDatasource.postgresql.schemaValidation === "STRICT"
) {
const postgresql = currentSchema.primaryDatasource.postgresql;
if (postgresql?.cloudSql.instance !== instanceId) {
logLabeledWarning(
"dataconnect",
`Switching connected Cloud SQL instance\nFrom ${postgresql?.cloudSql.instance}\nTo\n ${instanceId}`,
);
}
if (postgresql?.database !== databaseId) {
logLabeledWarning(
"dataconnect",
`Switching connected Postgres database from ${postgresql?.database} to ${databaseId}`,
);
}
if (!postgresql || postgresql.schemaValidation === "STRICT") {
return;
}
currentSchema.primaryDatasource.postgresql.schemaValidation = "STRICT";
try {
await upsertSchema(currentSchema, /** validateOnly=*/ false);
} catch (err: any) {
Expand Down

0 comments on commit 7b33e7e

Please sign in to comment.