package Ġle ight . upgrade Ċ Ċ import Ġle ight . container . Abstract Service Ċ import Ġle ight . container . I Container Ċ import Ġle ight . storage . I Storage Ċ import Ġle ight . utils . as Stamp Ċ import Ġorg . jetbrains . ex posed . sql . Schema Utils Ċ Ċ class ĠVersion Service ( container : ĠI Container ) Ġ: ĠAbstract Service ( container ), ĠI Version Service Ġ{ Ċ ĉ private Ġval Ġstorage : ĠI Storage Ġby Ġcontainer . lazy () ĊĊ ĉ override Ġfun Ġget Version (): ĠString ? Ġ= Ġtry Ġ{ Ċĉ ĉ get Collection (). first (). version Ċ ĉ } Ġcatch Ġ( e : ĠNoSuch ElementException ) Ġ{ Ċĉ ĉ null Ċ ĉ } ĊĊ ĉ override Ġfun Ġupgrade ( upgrade : ĠI Upgrade ) Ġ= Ġstorage . write Ġ{ Ċĉ ĉ Upgrade Entity . new Ġ{ Ċĉĉ ĉ version Ġ= Ġupgrade . getVersion () Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ override Ġfun Ġget Collection () Ġ= Ġstorage . read Ġ{ Ċĉ ĉ Upgrade Entity . all (). sorted By Descending Ġ{ Ġit . stamp Ġ}. iterator (). as Sequence (). as Iterable () Ċ ĉ } ĊĊ ĉ override Ġfun Ġprint () Ġ= Ġstorage . read Ġ{ Ċĉ ĉ for Ġ( version Ġin Ġget Collection ()) Ġ{ Ċĉĉ ĉ println ("\ t [ ${ version . stamp . as Stamp ()} ]: Ġ${ version . version }") Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ override Ġfun Ġon Setup () Ġ= Ġstorage . transaction Ġ{ Ċĉ ĉ Schema Utils . create ( Upgrade Table ) Ċ ĉ } Ċ } Ċ