Passing output from one job to another

I have a deployment job that may or may not run some database migrations as part of the deployment. In the rollback job, I would like to also rollback those migrations. In order to do that, I need to know which migrations were actually run during the deploy job.

In my deploy job, I can output the names of all the migrations that were applied, but I can’t seem to find a way to make sure that those are available for the rollback job. I could output them to a file, store that as an artefact and then read it in the rollback job, but as far as I’m aware there’s no guarantee that the artefacts will be available.

Is there some way to do this with Gitlab CI, or am I going to need to write the file to S3, identifying it with the build number, in order to be able to guarantee myself access in the rollback job?