db.changelog.20200122-service-account-on-delivery-config.yml Maven / Gradle / Ivy
databaseChangeLog:
- changeSet:
id: service-account-on-delivery-config
author: fletch
changes:
- addColumn:
tableName: delivery_config
columns:
- column:
name: service_account
type: varchar(255)
constraints:
nullable: true
- sql:
sql: >
update delivery_config dc
set service_account = (
select substr(
r.metadata,
(locate('"serviceAccount":"', r.metadata) + 18),
locate('"', r.metadata, (locate('"serviceAccount":"', r.metadata) + 18)) - (locate('"serviceAccount":"', r.metadata) + 18)
) as service_account
from resource r, environment_resource er, environment e
where er.resource_uid = r.uid
and er.environment_uid = e.uid
and e.delivery_config_uid = dc.uid
limit 1
)
- addNotNullConstraint:
tableName: delivery_config
columnName: service_account
columnDataType: varchar(255)
rollback:
- dropColumn:
tableName: delivery_config
columnName: service_account