Upgrade to Pro — share decks privately, control downloads, hide ads and more …

flyway-play

 flyway-play

Toshiyuki Takahashi

August 01, 2015
Tweet

More Decks by Toshiyuki Takahashi

Other Decks in Programming

Transcript

  1. qZXBZQMBZ
    &BTZ%BUBCBTF.JHSBUJPOGPS1MBZ
    TDBMBؔ੢4VNNJU

    View full-size slide

  2. %BUBCBTFNJHSBUJPOJTEJGpDVMU

    View full-size slide

  3. %#
    w .VUBCMF
    w MJLFBHMPCBMWBSJBCMFTUBUF

    View full-size slide

  4. %&7TBZT
    w l4FUVQEBUBCBTFNBOVBMMZ z
    w l)PXUPSFWJFXDIBOHFT z
    w l8IPDIBOHFEUIJTTDIFNB z
    w l*GUFTUECEJGGFSTGSPNQSPE QSPEJT
    UIFSFBMz

    View full-size slide

  5. %#"TBZT
    w l*EPO`ULOPXNVDIBCPVUBQQz
    w l)FZ%&7 HJWFNF"-5&3TDSJQUz

    View full-size slide

  6. %BUBCBTFNJHSBUJPOJTEJGpDVMU

    View full-size slide

  7. (PBM
    w $PPQFSBUJPOCFUXFFO%&7BOE%#"
    w .BOBHFEBUBCBTFDIBOHFT

    View full-size slide

  8. 'MZXBZNBEFJUFBTZ

    View full-size slide

  9. 8IBUJT'MZXBZ

    View full-size slide

  10. 'MZXBZ
    w 0QFOTPVSDFEBUBCBTFNJHSBUJPOUPPM
    w 8SJUUFOJO+BWB
    w ;FSPSFRVJSFEEFQFOEFODJFTPUIFSUIBO
    +BWBBOE+%#$
    w 4VQQPSU42-CBTFE+BWBCBTFE
    NJHSBUJPO
    w 1PSUBCMF

    View full-size slide

  11. 4VQQPSUFEEBUBCBTFT
    w 0SBDMF
    w .Z42-
    w 1PTUHSF42-
    w %#
    w )
    w TPMJE%#
    w 42-4FSWFS
    w .BSJB%#
    w 7FSUJDB
    w %#[04
    w )TRM
    w 42-"[VSF
    w (PPHMF$MPVE42-
    w "843FETIJGU
    w %FSCZ
    w 42-JUF

    View full-size slide

  12. 1PSUBCMF
    w .BWFO
    w TCU
    w (SBEMF
    w "OU
    w $PNNBOE-JOF
    w +BWB"1*

    View full-size slide

  13. $PNNBOET
    w NJHSBUF
    w DMFBO
    w SFQBJS
    w JOGP
    w WBMJEBUF
    w CBTFMJOF

    View full-size slide

  14. 42-CBTFE.JHSBUJPO
    create table language (

    id integer primary key,

    name varchar(100) not null

    );

    View full-size slide

  15. +BWBCBTFE.JHSBUJPO
    package db.migration.java


    import java.sql.Connection


    import org.flywaydb.core.api.migration.jdbc.JdbcMigration


    class V1__Create_language_table extends JdbcMigration {

    override def migrate(conn: Connection): Unit = {


    conn.createStatement().executeUpdate(

    """create table language (

    | id integer primary key,

    | name varchar(100) not null

    |);""".stripMargin)

    }

    }

    View full-size slide

  16. IUUQXXXUIPVHIUXPSLTDPNSBEBSUPPMTqZXBZ
    ⚫"EPQU

    View full-size slide

  17. 8%#13&447PM
    +BWBͷ຺߭ʲୈճʳ
    'MZXBZʹΑΔޮ཰తͳ%#εΩʔϚ؅ཧ

    View full-size slide

  18. 8IBUJTqZXBZQMBZ

    View full-size slide

  19. qZXBZQMBZ
    w 'MZXBZNPEVMFGPS1MBZ
    w QMBZqZXBZJTBWBJMBCMFGPS

    View full-size slide

  20. libraryDependencies ++= Seq(

    "org.flywaydb" %% "flyway-play" % "2.1.0"

    )
    play.modules.enabled += "org.flywaydb.play.PlayModule"
    CVJMETCU
    BQQMJDBUJPODPOG

    View full-size slide

  21. 8IZOPUQMBZFWPMVUJPOT

    View full-size slide

  22. QMBZFWPMVUJPOT
    w EFQFOETPO1MBZ
    w JT XBT
    OPUDBQBCMFPGJOUFHSBUJOH
    XJUITPNFEBUBCBTFMJCSBSJFTUIBUEPO`U
    EFQFOEPOQMBZBQJEC
    w JTOPUTPqFYJCMF

    View full-size slide

  23. %JGGFSFODFGSPNQMBZFWPMVUJPOT

    View full-size slide

  24. w 6QT%PXOT
    w .BSLFSDPNNFOU
    QMBZFWPMVUJPOT

    View full-size slide

  25. qZXBZQMBZ
    w /Pb%PXOT`QBSU
    w 1MBJO42-

    View full-size slide

  26. QMBZFWPMVUJPOT
    w TRM TRM TRM ʜ

    View full-size slide

  27. qZXBZQMBZ
    w 0OFPSNPSFOVNFSJDQBSUT
    w 4FQBSBUFECZBEPU
    PSBO
    VOEFSTDPSF @

    w 6OEFSTDPSFTBSFSFQMBDFECZEPUT
    BUSVOUJNF
    w -FBEJOH[FSPFTBSFJHOPSFEJOFBDI
    QBSU
    "WFSTJPONVTUIBWF
    UIFGPMMPXJOHTUSVDUVSF

    View full-size slide

  28. qZXBZQMBZ
    w
    w
    w
    w @ BUSVOUJNF

    w
    w
    w
    w
    w
    &YBNQMFTPGWBMJEWFSTJPO

    View full-size slide

  29. QMBZFWPMVUJPOT
    TRM
    TRM
    DPOqJDUNFSHF
    TRM

    View full-size slide

  30. QMBZFWPMVUJPOT

    View full-size slide

  31. QMBZFWPMVUJPOT
    7@@ʜʜTRM
    7@@ʜʜTRM
    7@@ʜʜTRM
    OPDPOqJDUT

    View full-size slide

  32. 5JQTVTFDBTFT

    View full-size slide

  33. &NCFEJOZPVSBQQ
    w 'MZXBZIBT+BWB"1*
    w &BTZUPFNCFEJOBQQ UFTU
    val flyway = new Flyway

    flyway.setDataSource(dataSource)

    flyway.migrate()


    View full-size slide

  34. &YJTUJOHEBUBCBTFTFUVQ
    qZXBZCBTFMJOF%qZXBZCBTFMJOF7FSTJPO
    %qZXBZCBTFMJOF%FTDSJQUJPO#BTFWFSTJPO
    IUUQqZXBZECPSHEPDVNFOUBUJPOFYJTUJOHIUNM

    View full-size slide

  35. 'SPN$-*
    w 4CU .BWFO (SBEMFJOEFWFOWJSPONFOU
    w $-*UPPMJOQSPE

    View full-size slide

  36. XJUITMJDLDPEFHFO
    w QJUGBMM
    qZXBZQMBZEPFTO`UXPSLXJUI
    TMJDLDPEFHFO
    w qZXBZQMBZFGGFDUTPOTUBSUJOHUIF
    QMBZBQQ
    w TMJDLDPEFHFOFGGFDUTJODPNQJMFUJNF
    w 6TFTCUQMVHJOJOTUFBE

    View full-size slide

  37. XJUITMJDLDPEFHFO
    w IUUQTHJUIVCDPNUPUPUPTIJTCUTMJDLDPEFHFOFYBNQMF

    View full-size slide

  38. w 'MZXBZNBLFTECNJHSBUJPOFBTZ
    w TJNQMF QPSUBCMFBOEQPXFSGVM
    w 5SZJGZPVBSFJOUSPVCMFXJUIQMBZ
    FWPMVUJPOT

    View full-size slide