zrhoffman commented on code in PR #7309: URL: https://github.com/apache/trafficcontrol/pull/7309#discussion_r1088349239
########## traffic_ops/app/db/migrations/2023012316280200_create_new_role.down.sql: ########## @@ -0,0 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +DELETE FROM public.role_capability rc WHERE rc.role_id='trouter' + ON CONFLICT DO NOTHING; Review Comment: No need to delete from `role_capability` here, since `role_id` is a foreign key an `DELETE` cascasdes https://github.com/apache/trafficcontrol/blob/396d474320f0628b72bb407efc795ac4cacde6cd/traffic_ops/app/db/create_tables.sql#L3772-L3773 ########## traffic_ops/app/db/migrations/2023012316280200_create_new_role.up.sql: ########## @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +INSERT INTO public."role" (name, description, priv_level) +VALUES('trouter', 'Limited role for Traffic Router calls to Traffic Ops', 10); + +INSERT INTO public.role_capability (role_id, cap_name) + VALUES ((select id from role where name='trouter'), UNNEST('{CDN:READ, DELIVERY-SERVICE:READ, DNS-SEC:READ, FEDERATION:READ, STEERING:READ, FEDERATION-RESOLVER:READ, DS-SECURITY-KEY:READ}'::text[])) Review Comment: No need for the array of capabilities to be a string, it can be something like ```sql UNNEST(ARRAY['CDN:READ', 'DELIVERY-SERVICE:READ', 'DNS-SEC:READ', 'FEDERATION:READ', 'STEERING:READ', 'FEDERATION-RESOLVER:READ', 'DS-SECURITY-KEY:READ']) ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
