@@ -433,3 +433,22 @@ WHERE %s
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *Mesure) Delete(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
) error {
|
||||
q := `
|
||||
DELETE FROM mesures
|
||||
WHERE %s
|
||||
AND id = @mesure_id
|
||||
`
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"mesure_id": m.ID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
return err
|
||||
}
|
||||
|
||||
7
pkg/coredata/migrations/20250417T085900Z.sql
Normal file
7
pkg/coredata/migrations/20250417T085900Z.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
ALTER TABLE evidences DROP CONSTRAINT evidences_task_id_fkey;
|
||||
|
||||
ALTER TABLE evidences
|
||||
ADD CONSTRAINT evidences_task_id_fkey
|
||||
FOREIGN KEY (task_id)
|
||||
REFERENCES tasks(id)
|
||||
ON DELETE CASCADE;
|
||||
Reference in New Issue
Block a user