Suppose that $S$ is smooth and that $U\subset S$ is a dense open subscheme. Let $X$ be a scheme (not necessarily smooth) and let $f:X\to U$ be a finite flat morphism. I would like to know whether this finite flat family can be extended over $S$, and whether such an extension is unique. More precisely:


1. Does there always exist a scheme $Y$ and a finite flat morphism $g:Y\to S$ such that $g^{-1}(U)$ is isomorphic to $X$ as a scheme over $U$?
2. Given two such extensions, do they have to be isomorphic?



Existence and uniqueness of extensions of a finite flat map
$\def\cO{\mathcal{O}}\def\cE{\mathcal{E}}$I will show that the answer to (1) is yes if and only if the vector bundle $f\_{\ast} \cO\_X$ on $U$ extends to a vector bundle on $S$. Moreover, if $S \setminus U$ is codimension $\geq 2$ in $S$, I will show that the extension is unique as well.


This condition is obviously necessary. 




---


Here is an example of a case where $f\_{\ast} \cO\_X$ does not extend. Start with [Steven Landsburg's example](https://mathoverflow.net/a/92292/297) (well, Swan's example, but Landsburg is easier to cite) of a vector bundle $V$ on $U:=\mathbb{A}^3 \setminus \{ 0 \}$ which doesn't extend $S:=\mathbb{A}^3$. If we take global sections of $V$ over $U$, we get $M:= \{ (f,g,h) \in k[x,y,z]^3 : xf+yg+zh=0 \}$. Note that, if $V$ did extend to a bundle on $S$, then every section of $V$ over $U$ would extend to a section of $S$ by Hartog, so $M$ would be a projective $k[x,y,z]$ module, but it isn't; this gives a proof that $V$ doesn't extend. $V$ doesn't quite do the job for us; we need $V \oplus T$, where $T$ is a trivial bundle. But that doesn't extend either for the same reason: If it did, then $M \oplus k[x,y,z]$ would be a projective $k[x,y,z]$ module, but then its summand $M$ would be, a contradiction. 


Now, let $V^{\ast}$ be the dual bundle to $V$. Let $\mathcal{I}$ be the ideal sheaf of the zero section of $V^{\ast} \to U$ and set $X = \mathcal{O}\_{V^{\ast}}/\mathcal{I}^2$. Then $f\_{\ast} \cO\_X \cong \mathcal{V} \oplus \cO\_U$, where $\mathcal{V}$ is the sheaf of sections of $V$. In other words, $f\_{\ast} \cO\_X$ is the sheaf of sections of $V \oplus T$.




---


I now prove that, if the vector bundle extends, then so does $X$.


Set $Z = S \setminus U$ and assume that $f\_{\ast} \cO\_X$ extends to a vector bundle on $S$. I'll write $E$ for the total space of the bundle and $\cE$ for the sheaf of sections.


**Extending in codimension $1$** We note that $X$ embeds in $E^{\ast}$ (the dual bundle) such that $f$ is the coordinate projection. The way this works is the following: Let $\mathcal{R}$ be the graded $\cO\_U$-algebra $\cO\_U \oplus (f\_{\ast} \cO\_X) \oplus (f\_{\ast} \cO\_X) \oplus \cdots$. Then $\mathrm{Proj} \mathcal{R} \cong X$. There is a map of $\cO\_S$ algebras $\mathrm{Sym}^{\bullet} \cE \to \mathcal{R}$, which gives an embedding $X \to \mathbb{P}(E^{\ast})$. ([Vakil](http://math.stanford.edu/~vakil/216blog/FOAGapr2915public.pdf), Exercise 7.3.J uses this trick to show finite maps are projective.)


So we get a map from $U$ to the Hilbert scheme of $\mathbb{P}(E^{\ast})/S$. Hilbert schemes are proper, and $S$ is smooth, so this map extends in codimension $1$. Thus, we may assume that $\mathrm{codim} Z \geq 2$.


**Beyond codimension $1$** Now assume that $\mathrm{codim} Z \geq 2$. In this case, the extension of $f\_{\ast} \cO\_X$ to a vector bundle on $S$ can occur in at most one way.


The multiplicative identity of $\cO\_X$ gives an section of $E$ over $U$. By Hartog's theorem, this section uniquely extends to a section $e: S \to E$. Similarly, the multiplication map $\mu : \cO\_X \otimes\_{\cO\_S} \cO\_X \to \cO\_X$ gives a section of $\mathrm{Hom}(E \otimes E, E)$ over $U$, which extends uniquely to a section $\mu$ over $S$. The condition that $\mu$ and $e$ define the structure of a unital commutative algebra on $\cE$ is a closed condition, so they do. This uniquely equips $\cE$ with the structure of a (commutative, unital) $\cO\_S$ algebra, and (relative) Spec of that algebra gives your $Y$.


