Update `update_circuit` admin store operation
Updates the `update_circuit` admin store diesel operation to remove the
circuit's associated members before attempting to add the updated
members which leads to a `ConstraintViolationError`. Also adds a line to
update the `circuit_status` column in the database.
@@ -61,6 +61,7 @@ impl<'a> AdminServiceStoreUpdateCircuitOperation
circuit::durability.eq(circuit_model.durability),
circuit::routes.eq(circuit_model.routes),
circuit::circuit_management_type.eq(circuit_model.circuit_management_type),
+ circuit::circuit_status.eq(circuit_model.circuit_status),
))
.execute(self.conn)?;
// Delete existing data associated with the `Circuit`
@@ -71,6 +72,10 @@ impl<'a> AdminServiceStoreUpdateCircuitOperation
.filter(service_argument::circuit_id.eq(circuit.circuit_id())),
)
.execute(self.conn)?;
+ delete(
+ circuit_member::table.filter(circuit_member::circuit_id.eq(circuit.circuit_id())),
+ )
+ .execute(self.conn)?;
// Insert new data associate with the `Circuit`
let services: Vec<ServiceModel> = Vec::try_from(&circuit)?;
insert_into(service::table)
@@ -115,6 +120,7 @@ impl<'a> AdminServiceStoreUpdateCircuitOperation
circuit::durability.eq(circuit_model.durability),
circuit::routes.eq(circuit_model.routes),
circuit::circuit_management_type.eq(circuit_model.circuit_management_type),
+ circuit::circuit_status.eq(circuit_model.circuit_status),
))
.execute(self.conn)?;
// Delete existing data associated with the `Circuit`
@@ -125,6 +131,10 @@ impl<'a> AdminServiceStoreUpdateCircuitOperation
.filter(service_argument::circuit_id.eq(circuit.circuit_id())),
)
.execute(self.conn)?;
+ delete(
+ circuit_member::table.filter(circuit_member::circuit_id.eq(circuit.circuit_id())),
+ )
+ .execute(self.conn)?;
// Insert new data associate with the `Circuit`
let services: Vec<ServiceModel> = Vec::try_from(&circuit)?;
insert_into(service::table)
