There are a lot of elephants in the room. And these are individual treaties of accession of the countries in question. Foreseeing possible such expansions, they sometimes have special provisions. Some examples, from a 2017 article:
Taoiseach Enda Kenny has asked recently for a special provision in any Brexit deal to allow Northern Ireland to rejoin the EU should it be united with the Republic. He did so, notwithstanding the fact that a special deal for Northern Ireland is the declared goal of the UK government.
So, the question is how could such a provision look like?
Obviously, there are not many EU law provisions that regulate the (re)unification of (Member-)States. The closest example is Article 4 of Protocol No 10 on Cyprus of the Act of Accession 2003. Protocol No 10 provides the terms for the application of EU law in Cyprus given that the island had not been unified at the moment it joined the EU. In particular, it provides for the suspension of the application of the acquis in northern Cyprus, a suspension which shall be lifted in the event of a solution.
If such solution occurs in the future, Article 4 provides for a simplified procedure that enables the Union to accommodate the terms of the reunification plan. In particular, Article 4 allows the EU, by a unanimous Council Decision at a future date and in the event of reunification, to alter the terms of Cyprus’ EU accession that are contained in the Act of Accession 2003. In other words, it allows the Council to amend primary law (ie the Act of Accession 2003) with a unanimous decision.
This might sound like a heresy. However, the Treaties foresee special procedures for their amendment in some cases. The best example, for the purposes of this post, is the Council decision on the basis of Article 2(2) of the 1994 Accession Treaty which adjusted the instruments of accession after Norway’s failure to ratify. Several Articles of this Accession Treaty and of the Act of Accession were amended by a Council decision while other provisions were declared to have lapsed. Thus, in that case, the Council, itself, amended primary law in a simplified procedure without any ratification of the Member States.
To the extent that the ‘Brexit’ Agreement will be considered as part of primary law, a similar provision regulating the reunification of Ireland could be included and could assist the smooth transitioning of Northern Ireland back to the EU. Of course, the question of the reunification of Ireland –as many other questions related to Brexit- is first and foremost political. It is important to point out, however, that EU law is flexible enough to accommodate such political developments.
So at least one reunification/expansion (that of Cyprus) is basically pre-ratified; well, there's an accelerated procedure for it already in place, probably inspired from the German precedent, in which the procedure was more ad-hoc, but it mostly involved the Council. The Cyprus case isn't terribly controversial though, because few countries recognise the Turkish/Northern Cyprus.