@@ -39,10 +39,10 @@ trait APIEndpointsMigrationHelper
3939 * @param string $apiName API identifier (e.g., 'summits')
4040 * @param string $endpointName Endpoint identifier (e.g., 'get-sponsor-extra-questions')
4141 * @param string $route Route pattern (e.g., '/api/v1/summits/{id}/sponsors/{sponsor_id}/extra-questions')
42- * @param string $httpMethod HTTP method as serialized PHP array (e.g., 'a:1:{i:0;s:3:" GET";} ')
42+ * @param string $httpMethod Plain HTTP method string (e.g., 'GET', 'POST', 'PUT', 'DELETE ')
4343 * @param bool $active Whether the endpoint is active (default: true)
44- * @param bool $allowCors Whether to allow CORS (default: false )
45- * @param bool $allowCredentials Whether to allow credentials (default: false )
44+ * @param bool $allowCors Whether to allow CORS (default: true, matches seedApiEndpoints behavior )
45+ * @param bool $allowCredentials Whether to allow credentials (default: true, matches seedApiEndpoints behavior )
4646 * @return string SQL INSERT statement
4747 */
4848 protected function insertEndpoint (
@@ -51,8 +51,8 @@ protected function insertEndpoint(
5151 string $ route ,
5252 string $ httpMethod ,
5353 bool $ active = true ,
54- bool $ allowCors = false ,
55- bool $ allowCredentials = false
54+ bool $ allowCors = true ,
55+ bool $ allowCredentials = true
5656 ): string {
5757 $ activeInt = $ active ? 1 : 0 ;
5858 $ corsInt = $ allowCors ? 1 : 0 ;
@@ -195,16 +195,22 @@ protected function deleteEndpointAuthzGroup(string $apiName, string $endpointNam
195195 /**
196196 * Generate DELETE for endpoint_api_scopes table (all associations for given scopes).
197197 *
198- * @param array $scopes List of scope URIs to remove associations for
198+ * Constrained by API to prevent removing associations for other APIs that may
199+ * reuse the same scope URI (api_scopes.name has no global uniqueness constraint).
200+ *
201+ * @param string $apiName API identifier (e.g., 'summits')
202+ * @param array $scopes List of scope URIs to remove associations for
199203 * @return string SQL DELETE statement
200204 */
201- protected function deleteScopesEndpoints (array $ scopes ): string
205+ protected function deleteScopesEndpoints (string $ apiName , array $ scopes ): string
202206 {
203207 $ scopeList = "' " . implode ("', ' " , $ scopes ) . "' " ;
204208 return <<<SQL
205209DELETE eas FROM endpoint_api_scopes eas
206210INNER JOIN api_scopes s ON s.id = eas.scope_id
207- WHERE s.name IN ( {$ scopeList });
211+ INNER JOIN apis a ON a.id = s.api_id
212+ WHERE a.name = ' {$ apiName }'
213+ AND s.name IN ( {$ scopeList });
208214SQL ;
209215 }
210216
0 commit comments