Migrate attachments s3 to new pattern

So remove the compatibility code altogether
This commit is contained in:
Guewen Baconnier
2016-11-01 08:55:00 +01:00
parent 963b65e99d
commit 1d4f76de2b
3 changed files with 27 additions and 33 deletions
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
import os
def migrate(cr, version):
cr.execute("""
SELECT value FROM ir_config_parameter
WHERE key = 'ir_attachment.location'
""")
row = cr.fetchone()
bucket = os.environ.get('AWS_BUCKETNAME')
if row[0] == 's3' and bucket:
cr.execute("""
UPDATE ir_attachment
SET store_fname = 's3://' || %s || '/' || store_fname
WHERE store_fname IS NOT NULL AND store_fname NOT LIKE '%%/%%'
""", (os.environ['AWS_BUCKETNAME'],))