runbot/runbot_merge/migrations/13.0.1.1/pre-migration.py
Xavier Morel ecd75b1822 [FIX] runbot_merge: statuses migration script should be for 13.0
Moving statuses from project to repo was originally developed on 11,
but since the PR was only merged after the 13.0 update, the script
migration script should be moved to match.
2020-01-29 13:29:21 +01:00

18 lines
651 B
Python

def migrate(cr, version):
""" Moved the required_statuses field from the project to the repository so
different repos can have different CI requirements within a project
"""
# create column on repo
cr.execute("ALTER TABLE runbot_merge_repository ADD COLUMN required_statuses varchar")
# copy data from project
cr.execute("""
UPDATE runbot_merge_repository r
SET required_statuses = (
SELECT required_statuses
FROM runbot_merge_project
WHERE id = r.project_id
)
""")
# drop old column on project
cr.execute("ALTER TABLE runbot_merge_project DROP COLUMN required_statuses")