{"id":21427850,"url":"https://github.com/playframework/flyway-play","last_synced_at":"2025-04-12T22:37:31.127Z","repository":{"id":25798883,"uuid":"29237658","full_name":"playframework/flyway-play","owner":"playframework","description":"Play modules for Flyway","archived":false,"fork":false,"pushed_at":"2025-03-17T20:49:17.000Z","size":1399,"stargazers_count":167,"open_issues_count":18,"forks_count":40,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-04-12T06:22:09.387Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/playframework.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["playframework"],"open_collective":"playframework"}},"created_at":"2015-01-14T09:47:28.000Z","updated_at":"2025-03-17T20:49:22.000Z","dependencies_parsed_at":"2023-02-19T07:31:15.290Z","dependency_job_id":"523b00c4-3037-4a23-9698-20641a6a54b0","html_url":"https://github.com/playframework/flyway-play","commit_stats":null,"previous_names":["playframework/flyway-play","flyway/flyway-play"],"tags_count":68,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playframework%2Fflyway-play","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playframework%2Fflyway-play/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playframework%2Fflyway-play/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playframework%2Fflyway-play/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/playframework","download_url":"https://codeload.github.com/playframework/flyway-play/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248643009,"owners_count":21138353,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-22T22:04:56.744Z","updated_at":"2025-04-12T22:37:31.103Z","avatar_url":"https://github.com/playframework.png","language":"Scala","readme":"# flyway-play\n\n![Scala CI](https://github.com/flyway/flyway-play/workflows/Scala%20CI/badge.svg)\n\nFlyway module for Play 2.4 or later. It aims to be a substitute for play-evolutions.\n\n## \u003ca class=\"anchor\" name=\"features\"\u003e\u003c/a\u003eFeatures\n\n- Based on [Flyway](https://flywaydb.org/)\n- No 'Downs' part.\n- Independent of DBPlugin(play.api.db).\n\n## \u003ca class=\"anchor\" name=\"install\"\u003e\u003c/a\u003eInstall\n\n| flyway-play version | play version | flyway version |\n| ------------------- | ------------ | -------------- |\n| 9.1.0               | 3.0.x        | 9.16.0         |\n| 9.0.0               | 3.0.x        | 9.16.0         |\n| 8.0.1               | 2.9.x        | 9.16.0         |\n| 7.38.0              | 2.8.x        | 9.16.0         |\n| 7.21.0              | 2.8.x        | 8.5.0          |\n| 7.14.0              | 2.8.x        | 7.14.0         |\n| 6.5.0               | 2.8.x        | 6.5.7          |\n\nbuild.sbt\n\n```scala\nlibraryDependencies ++= Seq(\n  \"org.flywaydb\" %% \"flyway-play\" % \"9.1.0\"\n)\n```\n\nconf/application.conf\n\n```\nplay.modules.enabled += \"org.flywaydb.play.PlayModule\"\n```\n\n## Maintenance\n\nThis repository is a community project and not officially maintained by the Flyway Team at Redgate.\nThis project is looked after only by the open source community. Community Maintainers are people who have agreed to be contacted with queries for support and maintenance.\nCommunity Maintainers:\n\n- [@tototoshi](https://github.com/tototoshi)\n\nIf you would like to be named as a Community Maintainer, let us know via Twitter: https://twitter.com/flywaydb.\n\n## \u003ca class=\"anchor\" name=\"getting-started\"\u003e\u003c/a\u003eGetting Started\n\n### Basic configuration\n\nDatabase settings can be set in the manner of Play2.\n\n```\ndb.default.driver=org.h2.Driver\ndb.default.url=\"jdbc:h2:mem:example2;db_CLOSE_DELAY=-1\"\ndb.default.username=\"sa\"\ndb.default.password=\"secret\"\n\n# optional\ndb.default.migration.schemas=[\"public\", \"other\"]\n```\n\n### Place migration scripts\n\nA migration script is just a simple SQL file.\n\n```sql\nCREATE TABLE FOO (.............\n\n\n```\n\nBy default place your migration scripts in `conf/db/migration/${dbName}` .\n\nIf scriptsDirectory parameter is set, it will look for migrations scripts in `conf/db/migration/${scriptsDirectory}` .\n\n```\nplayapp\n├── app\n│   ├── controllers\n│   ├── models\n│   └── views\n├── conf\n│   ├── application.conf\n│   ├── db\n│   │   └── migration\n│   │       ├── default\n│   │       │   ├── V1__Create_person_table.sql\n│   │       │   └── V2__Add_people.sql\n│   │       └── secondary\n│   │           ├── V1__create_job_table.sql\n│   │           └── V2__Add_job.sql\n│   ├── play.plugins\n│   └── routes\n```\n\nAlternatively, specify one or more locations per database and place your migrations in `conf/db/migration/${dbName}/${locations[1...N]}` . By varying the locations in each environment you are able to specify different scripts per RDBMS for each upgrade. These differences should be kept minimal.\n\nFor example, in testing use the configuration:\n\n```\ndb.default.migration.locations=[\"common\",\"h2\"]\n```\n\nAnd in production use the configuration:\n\n```\ndb.default.migration.locations=[\"common\",\"mysql\"]\n```\n\nThen put your migrations in these folders. Note that the migrations for the `secondary` database remain in the default location.\n\n```\nplayapp\n├── app\n│   ├── controllers\n│   ├── models\n│   └── views\n├── conf\n│   ├── application.conf\n│   ├── db\n│   │   └── migration\n│   │       ├── default\n│   │       │   ├── common\n│   │       │   │   └── V2__Add_people.sql\n│   │       │   ├── h2\n│   │       │   │   └── V1__Create_person_table.sql\n│   │       │   └── mysql\n│   │       │       └── V1__Create_person_table.sql\n│   │       └── secondary\n│   │           ├── V1__create_job_table.sql\n│   │           └── V2__Add_job.sql\n│   ├── play.plugins\n│   └── routes\n```\n\nPlease see flyway's documents about the naming convention for migration scripts.\n\nhttps://flywaydb.org/documentation/migration/sql.html\n\n### Placeholders\n\nFlyway can replace placeholders in Sql migrations.\nThe default pattern is ${placeholder}.\nThis can be configured using the placeholderPrefix and placeholderSuffix properties.\n\nThe placeholder prefix, suffix, and key-value pairs can be specified in application.conf, e.g.\n\n```\ndb.default.migration.placeholderPrefix=\"$flyway{{{\"\ndb.default.migration.placeholderSuffix=\"}}}\"\ndb.default.migration.placeholders.foo=\"bar\"\ndb.default.migration.placeholders.hoge=\"pupi\"\n```\n\nThis would cause\n\n```sql\nINSERT INTO USERS ($flyway{{{foo}}}) VALUES ('$flyway{{{hoge}}}')\n```\n\nto be rewritten to\n\n```sql\nINSERT INTO USERS (bar) VALUES ('pupi')\n```\n\n### Enable/disable Validation\n\nFrom flyway 3.0, `validate` run before `migrate` by default.\nSet `validateOnMigrate` to false if you want to disable this.\n\n```\ndb.${dbName}.migration.validateOnMigrate=false // true by default\n```\n\n### Migration prefix\n\nCustom sql migration prefix key-value pair can be specified in application.conf:\n\n```\ndb.${dbName}.migration.sqlMigrationPrefix=\"migration_\"\n```\n\n### Insert Query\n\nIf you want to apply your migration not via the web interface, but manually on\nyour production databases you also need the valid insert query for flyway.\n\n```\ndb.${dbName}.migration.showInsertQuery=true\n```\n\n### Dev\n\n![screenshot](screenshot1.png)\n\nFor existing schema, Flyway has a option called 'initOnMigrate'. This option is enabled when `-Ddb.${dbName}.migration.initOnMigrate=true`.\nFor example,\n\n```\n$ play -Ddb.default.migration.initOnMigrate=true\n```\n\nOf course, You can write this in your `application.conf`.\n\nManual migration is also supported. Click 'Other operations' or open `/@flyway/${dbName}` directly.\n\n![screenshot](screenshot2.png)\n\n### Test\n\nIn Test mode, migration is done automatically.\n\n### Prod\n\nIn production mode, migration is done automatically if `db.${dbName}.migration.auto` is set to be true in application.conf.\nOtherwise, it failed to start when migration is needed.\n\n```\n$ play -Ddb.default.migration.auto=true start\n```\n\n## \u003ca class=\"anchor\" name=\"example\"\u003e\u003c/a\u003eExample application\n\n[seratch/devteam-app](https://github.com/scalikejdbc/devteam-app \"seratch/devteam-app\") is using play-flyway. Maybe this is a good example.\n\n## compile-time DI support\n\n```scala\nclass MyComponents(context: Context)\n    extends BuiltInComponentsFromContext(context)\n    with FlywayPlayComponents\n    ...\n    {\n  flywayPlayInitializer\n  ...\n}\n```\n\n## \u003ca class=\"anchor\" name=\"license\"\u003e\u003c/a\u003eLicense\n\n- Apache 2.0 License\n","funding_links":["https://github.com/sponsors/playframework","https://opencollective.com/playframework"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplayframework%2Fflyway-play","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplayframework%2Fflyway-play","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplayframework%2Fflyway-play/lists"}