Add two new interfaces Upper and Downer, implemented by operations that create up and down triggers.
Consumers of pgroll may wish to identify operations that run arbitrary SQL via up and down triggers and pre-process them in such a way to ensure that the SQL is safe, or otherwise restricted.
With the new interfaces clients can do something like:
for _, op := range migration.Operations {
if up, ok := op.(migrations.Upper); ok {
processedSQL := processSQL(up.UpSQL())
up.SetUpSQL(processedSQL)
}
if down, ok := op.(migrations.Downer); ok {
processedSQL := processSQL(down.DownSQL())
down.SetDownSQL(processedSQL)
}
}
to iterate over all operations in a migration and process the up or down SQL of each operation.
Update the createTrigger function to check that the operation creating the trigger implements either Upper or Downer according to the direction of the trigger. This guards against future operations creating triggers without implementing Upper or Downer.
Add two new interfaces
Upper
andDowner
, implemented by operations that create up and down triggers.Consumers of
pgroll
may wish to identify operations that run arbitrary SQL viaup
anddown
triggers and pre-process them in such a way to ensure that the SQL is safe, or otherwise restricted.With the new interfaces clients can do something like:
to iterate over all operations in a migration and process the
up
ordown
SQL of each operation.Update the
createTrigger
function to check that the operation creating the trigger implements eitherUpper
orDowner
according to the direction of the trigger. This guards against future operations creating triggers without implementingUpper
orDowner
.