(options: Options, schema: Schema)
| 351 | } |
| 352 | |
| 353 | export 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 | |
| 386 | function diffsEqual(x: Diff[], y: Diff[]): boolean { |
| 387 | if (x.length !== y.length) { |
no test coverage detected
searching dependent graphs…