Pantheon Community

Discussion for doc: Migrate to Drupal 9 with empty upstream

Migrate to Drupal 9

Trying to update our D8 site D9. We very recently moved this site from another server to Pantheon, so our upstream is set to empty. We also already manage with composer.

I’m wondering how can I set my upstream to use Drupal 9? And then I think from there I would be able to follow the other steps in this documentation?

The Pantheon upstream for D9 is at GitHub - pantheon-upstreams/drupal-project: Template for new custom upstreams using Drupal and Composer on Pantheon… machine name drupal9, uuid e96c6794-77fe-4931-9a20-48a2fe1a3789. This upstream uses Integrated Composer for delivering updates, docs on Integrated Composer are here: https://pantheon.io/docs/integrated-composer

The process for switching upstreams is a bit complicated and delicate. The key is that the site’s git history needs to include the upstream’s git history in order for the platform to recognize when new updates arrive on the upstream. Even still, I have heard of people having difficulty switching from an empty custom upstream. For these reasons, it can be simpler to stand up a new Pantheon site and migrate over to it, although that may be more work because of the ‘relaunch’.

To switch to the upstream above, you’ll want to create a new branch and corresponding multidev to work on. On that branch, you’ll remove all the files, replace them with the files from the upstream, and re-add your code back in.

Add the new upstream as a second remote on your local clone. git rm -rf * and commit “removing all files”, then git merge --no-rebase -Xtheirs --allow-unrelated-histories --squash upstream/master. I believe that should add in all the upstream’s files as well as bringing in its git history. Then re-add your site’s custom code. Make sure that running composer install doesn’t modify any files which are committed to version control; anything that composer touches should be .gitignored. By design, Integrated Composer’s build step will abort if composer modifies anything tracked by git.

There is currently a platform bug where the first time you push a pantheon.yml with build_step: true added to it to a dev environment, the change doesn’t take. Another change to pantheon.yml needs to be committed and pushed for the build_step: true to start working. Make sure to do this on dev and confirm the IC build is working on dev before pushing to test and live, and the problem shouldn’t occur in those environments.

Once the rebuilt site is working on the multidev, you can merge to the master branch to deploy to dev, then apply another change to pantheon.yml to get build_step: true to kick in. Merging to the master branch will be much simpler if the master branch hasn’t changed since the multidev branch split off… else you will have merge conflicts to resolve.

1 Like

I forgot to include the last step: To actually switch the site’s upstream, you’ll use Terminus: terminus site:upstream:set <site> <upstream_id> where upstream_id is the machine name or uuid I mentioned in my first post.

Note that it may be quite some time before any actual code updates arrive on the upstream itself, because it no longer includes Drupal core directly; Integrated Composer handles updates to community code (composer packages) without any necessary changes to the upstream codebase.

1 Like

Thanks for this helpful information Brian. We might still do this in the future, but for now I decided to just do the upgrade to Drupal 9 independently and continue managing with Composer myself. I figured since the upstream is empty, there wouldn’t be any issues with that. We’re just not taking advantage of the automated updates that Pantheon would be providing.