MCPcopy Create free account
hub / github.com/firebase/firebase-tools / grantRoleToUserInSchema

Function grantRoleToUserInSchema

src/dataconnect/schemaMigration.ts:353–384  ·  view source on GitHub ↗
(options: Options, schema: Schema)

Source from the content-addressed store, hash-verified

351}
352
353export async function grantRoleToUserInSchema(options: Options, schema: Schema) {
354 const role = options.role as string;
355 const email = options.email as string;
356
357 const { serviceName, instanceId, instanceName, databaseId, schemaName } = getIdentifiers(schema);
358
359 await ensureServiceIsConnectedToCloudSql(
360 serviceName,
361 instanceName,
362 databaseId,
363 /* linkIfNotConnected=*/ false,
364 schemaName,
365 );
366
367 // Make sure we have the right setup for the requested role grant.
368 const schemaSetupStatus = await setupSchemaIfNecessary(
369 instanceId,
370 databaseId,
371 schemaName,
372 options,
373 );
374
375 // Edge case: we can't grant firebase owner unless database is greenfield.
376 if (schemaSetupStatus !== SchemaSetupStatus.GreenField && role === "owner") {
377 throw new FirebaseError(
378 `Owner rule isn't available in ${schemaSetupStatus} databases. If you would like SQL Connect to manage and own your database schema, run 'firebase dataconnect:sql:setup'`,
379 );
380 }
381
382 // Grant the role to the user.
383 await grantRoleTo(options, instanceId, databaseId, role, email, schemaName);
384}
385
386function diffsEqual(x: Diff[], y: Diff[]): boolean {
387 if (x.length !== y.length) {

Callers 1

Calls 4

grantRoleToFunction · 0.90
getIdentifiersFunction · 0.85
setupSchemaIfNecessaryFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…