MCPcopy Create free account
hub / github.com/cloudquery/cloudquery / getPKName

Method getPKName

plugins/destination/postgresql/client/migrate.go:481–492  ·  view source on GitHub ↗
(ctx context.Context, tableName string)

Source from the content-addressed store, hash-verified

479}
480
481func (c *Client) getPKName(ctx context.Context, tableName string) (string, error) {
482 var pkConstraintName string
483 err := c.conn.QueryRow(ctx, `SELECT tco.constraint_name FROM information_schema.table_constraints tco JOIN information_schema.key_column_usage kcu
484 ON kcu.constraint_name = tco.constraint_name
485 WHERE tco.constraint_type = 'PRIMARY KEY'
486 AND kcu.table_name = $1`, tableName).Scan(&pkConstraintName)
487 if err != nil && !errors.Is(err, pgx.ErrNoRows) {
488 return "", err
489 }
490
491 return pkConstraintName, nil
492}
493
494func (c *Client) createPerformanceIndexes(ctx context.Context, table *schema.Table) error {
495 columns := []string{"_cq_source_name", "_cq_sync_time"}

Callers 2

migrateToCQIDMethod · 0.95
createTableIfNotExistMethod · 0.95

Calls 2

ScanMethod · 0.80
QueryRowMethod · 0.65

Tested by

no test coverage detected