mirror of
https://github.com/odoo/runbot.git
synced 2025-03-17 00:15:47 +07:00

On per-repo status configurations, convert the "branch_ids" filter to a domain on branches. Since the selection is generally binary (statuses either apply to the master branch or apply to non-master branch) this avoids error-prone missed updates where we forget to enable statuses pretty much every time we fork off a new branch. Fixes #404
23 lines
663 B
Python
23 lines
663 B
Python
def migrate(cr, version):
|
|
""" copy required status filters from an m2m to branches to a domain
|
|
"""
|
|
cr.execute("""
|
|
ALTER TABLE runbot_merge_repository_status
|
|
ADD COLUMN branch_filter varchar
|
|
""")
|
|
cr.execute('''
|
|
SELECT status_id, array_agg(branch_id)
|
|
FROM runbot_merge_repository_status_branch
|
|
GROUP BY status_id
|
|
''')
|
|
for st, brs in cr.fetchall():
|
|
cr.execute("""
|
|
UPDATE runbot_merge_repository_status
|
|
SET branch_filter = %s
|
|
WHERE id = %s
|
|
""", [
|
|
repr([('id', 'in', brs)]),
|
|
st
|
|
])
|
|
cr.execute("DROP TABLE runbot_merge_repository_status_branch")
|