MM-58525 Fix upload file permissions (#27298)

* tie create_post and upload_file permissions together

* update tests

* update file name

* update migration to do in batches

* Update 000122_remove_upload_file_permission.up.sql

* fix formatting

* simplify migrations, fix regex issue

* update file names for recent merge

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Scott Bishel
2024-06-24 10:47:52 -06:00
коммит произвёл GitHub
родитель 6a2078ecf0
Коммит 71c25fb316
10 изменённых файлов: 130 добавлений и 10 удалений

Просмотреть файл

@@ -0,0 +1 @@
-- Skipping it because the forward migrations are destructive

Просмотреть файл

@@ -0,0 +1,18 @@
DO $$
<<remove_upload_file_permission>>
DECLARE
rows_updated integer;
BEGIN
LOOP
WITH table_holder AS (
SELECT id FROM roles
WHERE permissions ~~ '%upload_file%' AND permissions !~ 'create_post($|\s)'
ORDER BY id ASC limit 100
)
UPDATE Roles r set permissions = REGEXP_REPLACE(permissions, 'upload_file($|\s)', '')
WHERE r.id in (SELECT id FROM table_holder);
GET DIAGNOSTICS rows_updated = ROW_COUNT;
EXIT WHEN rows_updated < 100;
END LOOP;
END remove_upload_file_permission $$;