prevent duplicate snapshot panic by replacing existing rows to avoid unique constraint failure
diff --git a/apigee_sync_test.go b/apigee_sync_test.go index f461c2a..697b94f 100644 --- a/apigee_sync_test.go +++ b/apigee_sync_test.go
@@ -270,11 +270,8 @@ It("Should be able to handle duplicate snapshot during bootstrap", func() { initializeContext() - pie := apid.PluginsInitializedEvent{ - Description: "plugins initialized", - } - pie.Plugins = append(pie.Plugins, pluginData) - postInitPlugins(pie) + tokenManager = createTokenManager() + events.Listen(ApigeeSyncEventSelector, &handler{}) scopes := []string{apidInfo.ClusterID} snapshot := &common.Snapshot{}
diff --git a/data.go b/data.go index 4e5a62c..48f1ff7 100644 --- a/data.go +++ b/data.go
@@ -88,8 +88,9 @@ log.Debugf("inserting into APID_CLUSTER: %v", dac) + //replace to accomodate same snapshot txid stmt, err := txn.Prepare(` - INSERT INTO APID_CLUSTER + REPLACE INTO APID_CLUSTER (id, description, name, umbrella_org_app_name, created, created_by, updated, updated_by, last_sequence) @@ -117,8 +118,9 @@ log.Debugf("insert DATA_SCOPE: %v", ds) + //replace to accomodate same snapshot txid stmt, err := txn.Prepare(` - INSERT INTO DATA_SCOPE + REPLACE INTO DATA_SCOPE (id, apid_cluster_id, scope, org, env, created, created_by, updated, updated_by)