emeraldsquad/cf-flyway-resourceVersion control for your database so you can migrate it with ease and confidence to Cloud Foundry database services with concourse-ci and Flyway.
Features:
) username: ((product-name))-ciuser password: ((pcf-ciuser-passwd)) organization: ((product-name))-org space: ((pcf-space)) service: ((database-service-name))
yml- name: cf-flyway type: cf-flyway-resource source: api: cf-api-endpoint username: cf-user password: cf-user-password organization: organization-name space: space-name service: service-instance-name
The check script always returns the current version number, or generate an initial version if none was received.
Version is expressed as datetime (utc).
The in script always returns the current version number. Therefore, the resources cannot be used as an input trigger.
Read service information from the cf api to produce metadata.
ymlcf_api : [***] cf_org : organization-name cf_space : space-name dashboard_url : https://{hostname}/service-instances/53rv1c30-1n5t-aNc3-Gu1d-000000000000/ metadata_url : /v2/service_instances/53rv1c30-1n5t-aNc3-Gu1d-000000000000 service_instance : cf-db-service-instance-name service_label : cf-db-service-name service_plan : cf-db-service-plan
Migrate database schemas to CloudFoundry database service.
The out script creates a service-key on the Cloud Foundry database service. It then reads the credentials of the service-key and generate a flyway.conf file containing the Cloud Foundry database service-key url, username and password.
The generated flyway.conf file will also have flyway.cleanDisabled=true set by default.
Any other flyway configuration provided by the user is also appended to the generated flyway.conf file. Note that the out script will always override the following config:
confflyway.url={service-key jdbc:driver//url/database} # Overwritten by Cloud Foundry service-key credentials flyway.user={service-key username} # Overwritten by Cloud Foundry service-key credentials flyway.password={service-key password} # Overwritten by Cloud Foundry service-key credentials flyway.locations={params.locations} # Overwritten by locations parameter (required) flyway.cleanDisabled=true # Overwritten by clean_disabled parameter (optional, default=true)
The out script then execute flyway commands. If a command list parameters is set, they will be executed sequentialy. If no command list parameters are set, the script defaults to the following commands.
flyway infoflyway migrateflyway infoThe service-key can be automatically deleted by setting the delete_service_key flag to true.
Alternatively, the out script can push an lightweight flyway application and bind it to the Cloud Foundry database service. It then reads the credentials of the service-binding and generate a flyway.conf file containing the Cloud Foundry database service-key url, username and password.
The out script then execute flyway commands trough Cloud Foundry run-task command.
The application can be automatically unbinded and deleted by setting the delete_application flag to true.
This option is especially usefull when you Cloud Foundry platform has access to a database service while your Concourse instance does not.
The pushed flyway application uses the following manifest.
ymlapplications: - name: {service-instance-name}-flyway buildpacks: [binary_buildpack] health-check-type: process no-route: true instances: 0 # faster staging time disk_quota: 256M memory: 256M command: sleep 3600 # ensure the app will stop after 1h.
To open an ssh connection to the flyway application, first scale the application to one instance before starting it. Once the application is started you will be able to open an ssh connection.
bashcf scale {service-instance-name}-flyway -i 1
bashcf start {service-instance-name}-flyway
bashcf ssh {service-instance-name}-flyway
The flyway_cli inside the application container is already configured to connect to the Cloud Foundry database service.
bashvcap@xxxxxxxx-xxxx-xxxx-xxxx-xxxx:~$ cd app vcap@xxxxxxxx-xxxx-xxxx-xxxx-xxxx:~/app$ ./flyway info Flyway Community Edition 9.4.0 by Redgate Database: {database connection information} Schema version: << Empty Schema >> +-----------+---------+---------------------+------+--------------+---------+ | Category | Version | Description | Type | Installed On | State | +-----------+---------+---------------------+------+--------------+---------+ | Versioned | 1.0 | migration initial | SQL | | Success | +-----------+---------+---------------------+------+--------------+---------+
Remember to stop the application when finished
bashcf stop {service-instance-name}-flyway
classpath: point to a package on the classpath and may contain both SQL and Java-based migrations.filesystem: point to a directory on the filesystem, may only contain SQL migrations and are only scanned recursively down non-hidden directories.[info, migrate, info])true)false)flyway.urlflyway.userflyway.passwordflyway.locationsflyway.cleanDisabled$1.true (default): The resource will :
flyway.conf file.flyway_cli along with the generated flyway.conf and your migration files.run-task command.false : The resource will :
service-key on your database service.flyway.conf file.true. (default: false)true. (default: 1024M)true. (default: 1024M)true (default: 15)true (default: 3)1. Only use the required locations parameter
ymljobs: - name: deploy plan: - get: my-app-package - put: cf-flyway params: locations: filesystem:my-app-package/DB/Schema
2. Add a flyway configuration file
ymljobs: - name: deploy plan: - get: my-app-package - put: cf-flyway params: locations: filesystem:my-app-package/DB/Schema flyway_conf: my-app-package/DB/flyway.config
3. Add inline flyway configuration
ymljobs: - name: deploy plan: - get: my-app-package - put: cf-flyway params: locations: filesystem:my-app-package/DB/Schema flyway_conf: | flyway.schemas=dbo flyway.connectRetries=2
4. Use a command sequence
ymljobs: - name: deploy plan: - get: my-app-package - put: cf-flyway params: locations: filesystem:my-app-package/DB/Schema commands: [info, validate]
5. Use Flyway Pro feature
ymljobs: - name: deploy plan: - get: my-app-package - put: cf-flyway params: locations: filesystem:my-app-package/DB/Schema commands: [info, undo, info] flyway_conf: | flyway.licenseKey=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
6. Use jdbc_builder
ymljobs: - name: deploy plan: - get: my-app-package - put: cf-flyway params: locations: filesystem:my-app-package/DB/Schema jdbc_builder: | echo jdbc:postgresql://$(echo $1 | jq -r '.uri' | grep -Poh '(?<=@).*')
7. Use run_task and delete application when migration is complete
ymljobs: - name: deploy plan: - get: my-app-package - put: cf-flyway params: run_task: true delete_application: true locations: filesystem:my-app-package/DB/Schema
8. Use memory and disk_quota when migration is done on a PCF app
ymljobs: - name: deploy plan: - get: my-app-package - put: cf-flyway params: run_task: true locations: filesystem:my-app-package/DB/Schema memory: 256M disk_quota: 256M
The out script always returns a new version number.
Read service information from the cf api to produce metadata.
ymlcf_api : [***] cf_org : organization-name cf_space : space-name dashboard_url : https://{hostname}/service-instances/53rv1c30-1n5t-aNc3-Gu1d-000000000000/ metadata_url : /v2/service_instances/53rv1c30-1n5t-aNc3-Gu1d-000000000000 service_instance : cf-db-service-instance-name service_label : cf-db-service-name service_plan : cf-db-service-plan
探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
在 Linux 系统配置镜像服务
在 Docker Desktop 配置镜像
Docker Compose 项目配置
Kubernetes 集群配置 Containerd
K3s 轻量级 Kubernetes 镜像加速
VS Code Dev Containers 配置
MacOS OrbStack 容器配置
在宝塔面板一键配置镜像
Synology 群晖 NAS 配置
飞牛 fnOS 系统配置镜像
极空间 NAS 系统配置服务
爱快 iKuai 路由系统配置
绿联 NAS 系统配置镜像
QNAP 威联通 NAS 配置
Podman 容器引擎配置
HPC 科学计算容器配置
ghcr、Quay、nvcr 等镜像仓库
无需登录使用专属域名
需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单
免费版仅支持 Docker Hub 访问,不承诺可用性和速度;专业版支持更多镜像源,保证可用性和稳定速度,提供优先客服响应。
专业版支持 docker.io、gcr.io、ghcr.io、registry.k8s.io、nvcr.io、quay.io、mcr.microsoft.com、docker.elastic.co 等;免费版仅支持 docker.io。
当返回 402 Payment Required 错误时,表示流量已耗尽,需要充值流量包以恢复服务。
通常由 Docker 版本过低导致,需要升级到 20.x 或更高版本以支持 V2 协议。
先检查 Docker 版本,版本过低则升级;版本正常则验证镜像信息是否正确。
使用 docker tag 命令为镜像打上新标签,去掉域名前缀,使镜像名称更简洁。
来自真实用户的反馈,见证轩辕镜像的优质服务