import at.clockwork.security.domain.*

class UpdateScriptService {

	def run(def connection, def dataSourceFields) {

		Menu.executeQuery("""select id from Menu where name in (
		    'menu.approvedTimeByMinutes.label'
		    , 'menu.approvedBookingTime.label'
		    )""").each {
		    Menu menu = Menu.get(it)
		    if (menu) {
			    OperatorType2Menu.executeUpdate("delete from OperatorType2Menu where menu=?", menu)
			    User2Menu.executeUpdate("delete from User2Menu where menu=?", menu)
			    OperatorType2AutoStartedMenu.executeUpdate("delete from OperatorType2AutoStartedMenu where menu=?", menu)
			    menu.delete(flush:true)
			}
		}

		true
	}
}