diff --git a/postgresql/migratedb.d/17.sql b/postgresql/migratedb.d/17.sql new file mode 100644 index 000000000..23c15e27e --- /dev/null +++ b/postgresql/migratedb.d/17.sql @@ -0,0 +1,20 @@ + +DO +$$ +DECLARE +-- The version we know how to do migration from, at the end of a successful migration +-- we will no longer be at this version. + sourcever INTEGER := 16; + changes VARCHAR := 'Remove user ids from filepaths'; +BEGIN + IF (select max(version) from sda.dbschema_version) = sourcever then + RAISE NOTICE 'Changes: %', changes; + + UPDATE sda.files + SET submission_file_path = regexp_replace(submission_file_path, '^[^/]*/', ''); + + ELSE + RAISE NOTICE 'Schema migration from % to % does not apply now, skipping', sourcever, sourcever+1; + END IF; +END +$$ \ No newline at end of file