Skip to content

API based Schema Migration behind experimental flag. - #10944

Open
itsrakhil wants to merge 2 commits into
mainfrom
schemamigration
Open

API based Schema Migration behind experimental flag.#10944
itsrakhil wants to merge 2 commits into
mainfrom
schemamigration

Conversation

@itsrakhil

Copy link
Copy Markdown
Contributor

This adds the fdcapimigration experimental flag to src/experiments.ts and conditionally executes schema migration commands via the Firebase Data Connect (FDC) API Backend when enabled.

@itsrakhil
itsrakhil requested a review from joehan August 17, 2026 19:51

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the fdcapimigration experiment, allowing SQL schema migrations to be delegated to the FDC Backend instead of executing them locally via IAM. Key changes include adding the executeSchemaMigration client function, updating handleIncompatibleSchemaError to support this delegation, and adding corresponding unit tests. Feedback on the changes highlights a logic bug where superuser commands are incorrectly sent to the backend alongside owner commands, a style guide violation regarding the use of any types in the new client function, and a corresponding need to update the client unit tests to match the corrected types.

Comment thread src/dataconnect/schemaMigration.ts Outdated
Comment thread src/dataconnect/client.ts
Comment thread src/dataconnect/client.spec.ts
@itsrakhil
itsrakhil force-pushed the schemamigration branch 2 times, most recently from 5c33791 to 84118d6 Compare August 17, 2026 20:17
@itsrakhil
itsrakhil enabled auto-merge (squash) August 17, 2026 20:34
@itsrakhil
itsrakhil force-pushed the schemamigration branch 2 times, most recently from 5eb7c73 to 0b52a03 Compare August 17, 2026 22:42
@joehan

joehan commented Aug 17, 2026

Copy link
Copy Markdown
Member

/joe-review

@joehan joehan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Disclaimer: This draft review was generated by an AI review agent. Please verify all findings before acting on them.

Code Review Summary: API-based Schema Migration (firebase/firebase-tools)
This PR introduces the fdcapimigration experimental flag to delegate SQL schema migrations to the FDC Backend. It also adds client-side preflight validation for new NOT NULL constraints.

🟢 Strengths & LGTM Aspects
Correctly gates the new schema migration path behind the fdcapimigration experimental flag.
Good test coverage for the new preflight validation logic and the conditional execution flow.
Standard cleanup of sinon stubs in afterEach hooks.
🔴 Overview of Findings & Action Items
AI/Agent Artifacts: A significant number of empty JSDoc comment blocks (/**\n *\n */) were added to functions in client.ts and schemaMigration.ts. These should be removed.
TypeScript Safety:
options in performClientSidePreflightValidation is typed as any and is unused.
Redundant as any cast on riskTags check in schemaMigration.ts.
Extensive use of any / as any in schemaMigration.spec.ts for mocking Schema, IncompatibleSqlSchemaError, and Options. Use proper type assertions or partial types instead.
API Design: performClientSidePreflightValidation has unused parameters (options, instanceId, databaseId) that should be removed.
🟡 Nits & Suggestions
The regex in performClientSidePreflightValidation assumes table names are always quoted. Consider making quotes optional for robustness.

Comment thread src/dataconnect/client.ts Outdated
Comment thread src/dataconnect/schemaMigration.ts Outdated
Comment thread src/dataconnect/schemaMigration.ts Outdated
Comment thread src/dataconnect/schemaMigration.ts Outdated
Comment thread src/dataconnect/schemaMigration.ts Outdated
Comment thread src/dataconnect/schemaMigration.spec.ts Outdated
Comment thread src/dataconnect/schemaMigration.spec.ts Outdated
sinon.restore();
});

const schema: any = {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 [TypeScript Safety] Avoid any in tests

Rationale: Using any reduces type safety even in tests. Use type assertions to Schema or Partial<Schema> instead.

Suggested Fix:

  const schema = {
    name: "projects/p/locations/l/services/s/schemas/main",
  } as Schema;

Comment thread src/dataconnect/schemaMigration.spec.ts Outdated
Comment thread src/dataconnect/schemaMigration.spec.ts Outdated
@itsrakhil
itsrakhil force-pushed the schemamigration branch 15 times, most recently from c917173 to 997b586 Compare August 18, 2026 05:43
### Description
Updates a mocked `getIAMUser` return value in `schemaMigration.spec.ts` to use `"CLOUD_IAM_USER"` instead of `"IAM"` to satisfy the `UserType` interface and fix a TypeScript compilation error (TS2322).

### Scenarios Tested
- `npm run test:compile`
- `npx mocha src/dataconnect/schemaMigration.spec.ts`

### Sample Commands
N/A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants