cloudquery icon indicating copy to clipboard operation
cloudquery copied to clipboard

Bug: postgres trigger functions are removed from provider tables during fetch

Open mlozoya2 opened this issue 3 years ago • 1 comments

Describe the Bug

If trigger functions are defined on provider tables, they disappear while running cloudquery fetch. It seems to happen because a "sync" occurs as part of the fetch, which drops the provider tables and recreates them.

Expected Behavior

Trigger functions defined on provider tables to remain intact while running cloudquery fetch.

CloudQuery Version

v0.31.6

Steps to Reproduce

  • On a fresh postgres database, create a table for any resource (ex. aws_organizations_accounts) as specified by it's provider.
  • Create a trigger function on the table you've created, and verify that it is present on the table.
  • Run cloudquery fetch with the appropriate configuration to fetch the resource for the table you created.
  • Observe that the trigger is no longer present on the table.

Additional Context

For our use case, we define postgres tables that aggregate data from provider tables and non-provider tables. In order to keep those aggregation tables up-to-date, we need to place trigger functions on provider tables. So currently, we use migration scripts to create our database schema (provider tables, aggregation tables, trigger functions, etc.) prior to running cloudquery fetch. With the addition of sync as part of the fetch, we've observed our triggers disappearing.

mlozoya2 avatar Aug 12 '22 21:08 mlozoya2

This should be solved in v2 upcoming release

yevgenypats avatar Sep 18 '22 19:09 yevgenypats

Now that V1 has been released this should be solved. Please reopen or create a new issue if you continue to experience issues

bbernays avatar Oct 07 '22 16:10 bbernays