Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensureServiceIsConnectedToCloudSql only need to call backend when schemaValidation==NONE #8049

Merged
merged 4 commits into from
Dec 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/dataconnect/schemaMigration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import { logLabeledBullet, logLabeledWarning, logLabeledSuccess } from "../utils";
import * as errors from "./errors";

export async function diffSchema(

Check warning on line 29 in src/dataconnect/schemaMigration.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
schema: Schema,
schemaValidation?: SchemaValidation,
): Promise<Diff[]> {
Expand All @@ -53,8 +53,8 @@
} else {
logLabeledSuccess("dataconnect", `Database schema is compatible.`);
}
} catch (err: any) {

Check warning on line 56 in src/dataconnect/schemaMigration.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
if (err?.status !== 400) {

Check warning on line 57 in src/dataconnect/schemaMigration.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .status on an `any` value
throw err;
}
const invalidConnectors = errors.getInvalidConnectors(err);
Expand Down Expand Up @@ -82,8 +82,8 @@
logLabeledBullet("dataconnect", `generating schema changes, including optional changes...`);
await upsertSchema(schema, /** validateOnly=*/ true);
logLabeledSuccess("dataconnect", `no additional optional changes`);
} catch (err: any) {

Check warning on line 85 in src/dataconnect/schemaMigration.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
if (err?.status !== 400) {

Check warning on line 86 in src/dataconnect/schemaMigration.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .status on an `any` value
throw err;
}
const incompatible = errors.getIncompatibleSchemaError(err);
Expand All @@ -105,7 +105,7 @@
return diffs;
}

export async function migrateSchema(args: {

Check warning on line 108 in src/dataconnect/schemaMigration.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
options: Options;
schema: Schema;
/** true for `dataconnect:sql:migrate`, false for `deploy` */
Expand All @@ -130,8 +130,8 @@
try {
await upsertSchema(schema, validateOnly);
logger.debug(`Database schema was up to date for ${instanceId}:${databaseId}`);
} catch (err: any) {

Check warning on line 133 in src/dataconnect/schemaMigration.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
if (err?.status !== 400) {

Check warning on line 134 in src/dataconnect/schemaMigration.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .status on an `any` value
throw err;
}
// Parse and handle failed precondition errors, then retry.
Expand Down Expand Up @@ -183,8 +183,8 @@
setSchemaValidationMode(schema, validationMode);
try {
await upsertSchema(schema, validateOnly);
} catch (err: any) {

Check warning on line 186 in src/dataconnect/schemaMigration.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
if (err.status !== 400) {

Check warning on line 187 in src/dataconnect/schemaMigration.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .status on an `any` value
throw err;
}
// Parse and handle failed precondition errors, then retry.
Expand Down Expand Up @@ -543,6 +543,7 @@
{
postgresql: {
database: databaseId,
schemaValidation: "NONE",
cloudSql: {
instance: instanceId,
},
Expand All @@ -566,7 +567,8 @@
`Switching connected Postgres database from ${postgresql?.database} to ${databaseId}`,
);
}
if (!postgresql || postgresql.schemaValidation === "STRICT") {
if (!postgresql || postgresql.schemaValidation !== "NONE") {
// Skip provisioning connectvity if it is already connected.
return;
}
postgresql.schemaValidation = "STRICT";
Expand Down
Loading