Deleting a container of constraints

I am trying to remove a container of constraints after solving it to add a new set of constraints before resolving it:
@constraint(model, A[s=1:n], x[s] == y[s])

I tried
for s in 1:n delete(model, A[s]) end
or
delete.(Ref(model),A)

but I always get this error JULIA: MethodError: no method matching iterate(::Nothing)

Do you have a reproducible example?

julia> using JuMP

julia> model = Model()
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: NO_OPTIMIZER
Solver name: No optimizer attached.

julia> n = 3
3

julia> y = rand(n)
3-element Vector{Float64}:
 0.7139810928549708
 0.45354593999857173
 0.8483710062233065

julia> @variable(model, x[1:n])
3-element Vector{VariableRef}:
 x[1]
 x[2]
 x[3]

julia> @constraint(model, A[s = 1:n], x[s] == y[s])
3-element Vector{ConstraintRef{Model, MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64}, MathOptInterface.EqualTo{Float64}}, ScalarShape}}:
 A[1] : x[1] = 0.7139810928549708
 A[2] : x[2] = 0.45354593999857173
 A[3] : x[3] = 0.8483710062233065

julia> delete.(model, A)
3-element Vector{Nothing}:
 nothing
 nothing
 nothing

julia> unregister(model, :A)

julia> @constraint(model, A[s = 1:n], x[s] == y[s])
3-element Vector{ConstraintRef{Model, MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64}, MathOptInterface.EqualTo{Float64}}, ScalarShape}}:
 A[1] : x[1] = 0.7139810928549708
 A[2] : x[2] = 0.45354593999857173
 A[3] : x[3] = 0.8483710062233065

Note the need for unregister.

Thanks @odow

I am using direct_model with MOSEK which I construct a linear approximation for SOCP constraints to provide a hot start for the next run. Then I remove the linear approximation constraints and add a set of new variables and SOCP constraints.

Can I reuse the same model? Or should I create a new one?
If I have to create a new model, I believe I can’t share the constraints from the original model with the new model; what about variables?

Do you have a reproducible example with the full error message?

I am using direct_model with MOSEK

I would just use Model(Mosek.Optimizer). direct_model has its uses, but it also adds complexity because some things aren’t supported.

I construct a linear approximation for SOCP constraints

Mosek supports SOCP constraints, so why the need to approximate?