moved SQL to scripts