Let $Y$ be a smooth projective variety with a finite affine cover $\{U_1,...,U_r \}$. Suppose that we have a family of birational maps $\pi_i:V_i \to U_i$ with $V_i$ smooth quasi-projective for each $i\in\{1,...,r\}$ such that $K_{V_i} = \pi_i^*K_{U_i} + Ram(\pi_i)$, where in this case the ramification divisor $Ram(\pi_i)$ is supported in the exceptional locus $Exp(\pi_i)$ [See 1.41 Debarre's Book]. Suppose that we can glue the $V_i's$ to obtain a smooth projective variety $X$ with a morphism $\pi:X \to Y$ such that $\pi|_{V_i} = \pi_i$. My question is, how are related $K_X = \pi^*K_Y + Ram(\pi)$ with the local view $K_{V_i} =\pi_i^*K_{U_i} + Ram(\pi_i)$?.
Since the canonical divisor is a local construction, my intuition says that $K_X = \pi^*K_Y + \sum_i Ram(\pi_i)$, but I'm not sure if I am losing some data about the ramification divisor in the open intersections $V_i\cap V_j$. Can someone give me a reference or explain me how it's works or if I am wrong?