MCPcopy Create free account
hub / github.com/adlio/schema / Lock

Method Lock

postgres.go:22–27  ·  view source on GitHub ↗

Lock implements the Locker interface to obtain a global lock before the migrations are run.

(ctx context.Context, tx Queryer, tableName string)

Source from the content-addressed store, hash-verified

20// Lock implements the Locker interface to obtain a global lock before the
21// migrations are run.
22func (p postgresDialect) Lock(ctx context.Context, tx Queryer, tableName string) error {
23 lockID := p.advisoryLockID(tableName)
24 query := fmt.Sprintf("SELECT pg_advisory_lock(%s)", lockID)
25 _, err := tx.ExecContext(ctx, query)
26 return err
27}
28
29// Unlock implements the Locker interface to release the global lock after the
30// migrations are run.

Callers

nothing calls this directly

Calls 2

advisoryLockIDMethod · 0.95
ExecContextMethod · 0.65

Tested by

no test coverage detected