Move functions creation at database level