You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
1.1 KiB

  1. # -*- coding: utf-8 -*-
  2. # © 2015 ABF OSIELL <http://osiell.com>
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  4. from . import models
  5. def pre_init_hook(cr):
  6. cr.execute("SELECT 1 FROM pg_class WHERE relname = 'audittrail_rule'")
  7. if cr.fetchall():
  8. migrate_from_audittrail(cr)
  9. def migrate_from_audittrail(cr):
  10. cr.execute('ALTER TABLE audittrail_rule RENAME TO auditlog_rule')
  11. cr.execute('ALTER TABLE audittrail_rule_id_seq '
  12. 'RENAME TO auditlog_rule_id_seq')
  13. cr.execute('ALTER TABLE auditlog_rule RENAME COLUMN object_id TO model_id')
  14. cr.execute('ALTER TABLE audittrail_log RENAME TO auditlog_log')
  15. cr.execute('ALTER TABLE audittrail_log_id_seq '
  16. 'RENAME TO auditlog_log_id_seq')
  17. cr.execute('ALTER TABLE auditlog_log RENAME COLUMN object_id TO model_id')
  18. cr.execute('ALTER TABLE audittrail_log_line RENAME TO auditlog_log_line')
  19. cr.execute('ALTER TABLE audittrail_log_line_id_seq '
  20. 'RENAME TO auditlog_log_line_id_seq')
  21. cr.execute("UPDATE ir_model_data SET model='auditlog.rule' "
  22. "WHERE model='audittrail.rule'")