Let $X$ be a regular affine $\mathbb{C}$-scheme, $A$ a (finitely-generated) $\mathbb{C}$-algebra. Let $Y \subset X \times \mathrm{Spec}(A)$ be a closed subscheme of codimension $1$ such that for each $t \in \mbox{Spec}(A)$, the fiber $Y\_t$ is an effective Cartier divisor of $X \times \{t\}$. Is $Y$ flat over $\mbox{Spec}(A)$? In other words, does fiberwise Cartier imply globally Cartier?



Effective Cartier divisor is an open property
I assume that "scheme" means $\mathbb{C}$-scheme, and that the product is over $\mathbb{C}$. I also assume that $Y$ is a closed subscheme.


First (trivial) counterexample: take for $Y$ an effective Cartier divisor in $X\times t$ ($t\in \mathrm{Spec}(A)(\mathbb{C})$), viewed as a subscheme of $X\times \mathrm{Spec}(A)$. 


Second counterexample: if $X$ is a regular *curve*, every proper closed subscheme of $X$ is a Cartier divisor in $X$. So, take for $Y$ any closed subscheme not containing any fiber component, and not flat over $\mathrm{Spec}(A)$. 


