[GH-ISSUE #2611] modoboa-imap-migration extension installation error #1654

Closed
opened 2026-02-27 11:18:24 +03:00 by kerem · 4 comments
Owner

Originally created by @stefaweb on GitHub (Sep 23, 2022).
Original GitHub issue: https://github.com/modoboa/modoboa/issues/2611

Impacted versions

  • OS Type: Debian
  • OS Version: bullseye
  • Database Type: PostgreSQL
  • Database version: 13.8-0+deb11u1
  • Modoboa:2.0.1
  • installer used: Yes
  • Webserver: Nginx

Steps to reproduce

Current behavior

Hello,

I'm trying to install modoboa-imap-migration extensions and I got error when I tried to migrate the extension.

Installation:

# apt-get install python3-virtualenv python3-pip
# git clone https://github.com/modoboa/modoboa-imap-migration.git
# cd modoboa-imap-migration
# python3 setup.py install
# sudo -u modoboa -i
$ bash
modoboa@mailhub:~$ source /srv/modoboa/env/bin/activate
(env) modoboa@mailhub:~$ cd /srv/modoboa/instance
(env) modoboa@mailhub:~/instance$
(env) modoboa@mailhub:~/instance$ python3 manage.py migrate

And I got these errors. I don't really know what to do now.

Operations to perform:
  Apply all migrations: admin, auth, authtoken, contenttypes, core, dnstools, lib, limits, maillog, modoboa_amavis, modoboa_contacts, modoboa_imap_migration, modoboa_postfix_autoreply, modoboa_radicale, otp_static, otp_totp, relaydomains, reversion, sessions, sites, transport
Running migrations:
  Applying admin.0021_auto_20220922_1052...Traceback (most recent call last):
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.FeatureNotSupported: cannot alter type of a column used by a view or rule
DETAIL:  rule _RETURN on view dkim depends on column "id"

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/srv/modoboa/instance/manage.py", line 22, in <module>
    main()
  File "/srv/modoboa/instance/manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/core/management/base.py", line 89, in wrapped
    res = handle_func(*args, **kwargs)
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/core/management/commands/migrate.py", line 244, in handle
    post_migrate_state = executor.migrate(
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/migrations/executor.py", line 117, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/migrations/executor.py", line 227, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/migrations/migration.py", line 126, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/migrations/operations/fields.py", line 244, in database_forwards
    schema_editor.alter_field(from_model, from_field, to_field)
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/base/schema.py", line 608, in alter_field
    self._alter_field(model, old_field, new_field, old_type, new_type,
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/postgresql/schema.py", line 196, in _alter_field
    super()._alter_field(
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/base/schema.py", line 765, in _alter_field
    self.execute(
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/base/schema.py", line 145, in execute
    cursor.execute(sql, params)
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/utils.py", line 66, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
django.db.utils.NotSupportedError: cannot alter type of a column used by a view or rule
DETAIL:  rule _RETURN on view dkim depends on column "id"

(env) modoboa@mailhub-aweb:~/instance$ python manage.py migrate modoboa_imap_migration
Operations to perform:
  Apply all migrations: modoboa_imap_migration
Running migrations:
  No migrations to apply.
  Your models in app(s): 'modoboa_imap_migration' have changes that are not yet reflected in a migration, and so won't be applied.
  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.
Originally created by @stefaweb on GitHub (Sep 23, 2022). Original GitHub issue: https://github.com/modoboa/modoboa/issues/2611 # Impacted versions * OS Type: Debian * OS Version: bullseye * Database Type: PostgreSQL * Database version: 13.8-0+deb11u1 * Modoboa:2.0.1 * installer used: Yes * Webserver: Nginx # Steps to reproduce # Current behavior Hello, I'm trying to install modoboa-imap-migration extensions and I got error when I tried to migrate the extension. Installation: ``` # apt-get install python3-virtualenv python3-pip # git clone https://github.com/modoboa/modoboa-imap-migration.git # cd modoboa-imap-migration # python3 setup.py install # sudo -u modoboa -i $ bash modoboa@mailhub:~$ source /srv/modoboa/env/bin/activate (env) modoboa@mailhub:~$ cd /srv/modoboa/instance (env) modoboa@mailhub:~/instance$ (env) modoboa@mailhub:~/instance$ python3 manage.py migrate ``` And I got these errors. I don't really know what to do now. ``` Operations to perform: Apply all migrations: admin, auth, authtoken, contenttypes, core, dnstools, lib, limits, maillog, modoboa_amavis, modoboa_contacts, modoboa_imap_migration, modoboa_postfix_autoreply, modoboa_radicale, otp_static, otp_totp, relaydomains, reversion, sessions, sites, transport Running migrations: Applying admin.0021_auto_20220922_1052...Traceback (most recent call last): File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) psycopg2.errors.FeatureNotSupported: cannot alter type of a column used by a view or rule DETAIL: rule _RETURN on view dkim depends on column "id" The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/srv/modoboa/instance/manage.py", line 22, in <module> main() File "/srv/modoboa/instance/manage.py", line 18, in main execute_from_command_line(sys.argv) File "/srv/modoboa/env/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line utility.execute() File "/srv/modoboa/env/lib/python3.9/site-packages/django/core/management/__init__.py", line 413, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/srv/modoboa/env/lib/python3.9/site-packages/django/core/management/base.py", line 354, in run_from_argv self.execute(*args, **cmd_options) File "/srv/modoboa/env/lib/python3.9/site-packages/django/core/management/base.py", line 398, in execute output = self.handle(*args, **options) File "/srv/modoboa/env/lib/python3.9/site-packages/django/core/management/base.py", line 89, in wrapped res = handle_func(*args, **kwargs) File "/srv/modoboa/env/lib/python3.9/site-packages/django/core/management/commands/migrate.py", line 244, in handle post_migrate_state = executor.migrate( File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/migrations/executor.py", line 117, in migrate state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial) File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial) File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/migrations/executor.py", line 227, in apply_migration state = migration.apply(state, schema_editor) File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/migrations/migration.py", line 126, in apply operation.database_forwards(self.app_label, schema_editor, old_state, project_state) File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/migrations/operations/fields.py", line 244, in database_forwards schema_editor.alter_field(from_model, from_field, to_field) File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/base/schema.py", line 608, in alter_field self._alter_field(model, old_field, new_field, old_type, new_type, File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/postgresql/schema.py", line 196, in _alter_field super()._alter_field( File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/base/schema.py", line 765, in _alter_field self.execute( File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/base/schema.py", line 145, in execute cursor.execute(sql, params) File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/utils.py", line 66, in execute return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers return executor(sql, params, many, context) File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/utils.py", line 90, in __exit__ raise dj_exc_value.with_traceback(traceback) from exc_value File "/srv/modoboa/env/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) django.db.utils.NotSupportedError: cannot alter type of a column used by a view or rule DETAIL: rule _RETURN on view dkim depends on column "id" (env) modoboa@mailhub-aweb:~/instance$ python manage.py migrate modoboa_imap_migration Operations to perform: Apply all migrations: modoboa_imap_migration Running migrations: No migrations to apply. Your models in app(s): 'modoboa_imap_migration' have changes that are not yet reflected in a migration, and so won't be applied. Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them. ```
kerem closed this issue 2026-02-27 11:18:24 +03:00
Author
Owner

@stefaweb commented on GitHub (Sep 23, 2022):

Hi!

I finally finished the setup. Working now.

python manage.py makemigrations
python manage.py migrate modoboa_imap_migration

It seems that transforming the address of a domain is not working.

Old server: user1@domainA.tld
New server: user1@domainB.tld

In the new server: domainB.tld

Associated domains

domainA.tld -> domainB.tld

The sync do not work (WRONG AUTH). If we don't use it. It works with the same accounts/domains.

root@mailhub:/srv/vmail# sudo -u vmail -i
$ cd /srv/vmail && /srv/modoboa/env/bin/python /srv/modoboa/instance/manage.py generate_offlineimap_config --output .offlineimaprc && /usr/bin/offlineimap
OfflineIMAP 8.0.0
  Licensed under the GNU GPL v2 or any later version (with an OpenSSL exception)
imaplib2 v3.05, Python v3.9.2, OpenSSL 1.1.1n  15 Mar 2022
Account sync sleclerc@domainA.tld:
 *** Processing account support@adomainA.tld
 Establishing connection to mailhub.xxxxxxx.eu:993 (Remote_support@domainA.tld)
 Establishing connection to localhost:143 (Local_support@domainA.tld)
 PLAIN authentication failed: b'[AUTHENTICATIONFAILED] Authentication failed.'
 LOGIN authentication failed: b'[AUTHENTICATIONFAILED] Authentication failed.'
 ERROR: All authentication types failed:
	PLAIN: b'[AUTHENTICATIONFAILED] Authentication failed.'
	LOGIN: b'[AUTHENTICATIONFAILED] Authentication failed.'
 *** Finished account 'support@domainA.tld' in 0:08
ERROR: Exceptions occurred during the run!
ERROR: All authentication types failed:
	PLAIN: b'[AUTHENTICATIONFAILED] Authentication failed.'
	LOGIN: b'[AUTHENTICATIONFAILED] Authentication failed.'

Traceback:
  File "/usr/share/offlineimap3/offlineimap/accounts.py", line 298, in syncrunner
    self.__sync()
  File "/usr/share/offlineimap3/offlineimap/accounts.py", line 375, in __sync
    localrepos.getfolders()
  File "/usr/share/offlineimap3/offlineimap/repository/IMAP.py", line 681, in getfolders
    imapobj = self.imapserver.acquireconnection()
  File "/usr/share/offlineimap3/offlineimap/imapserver.py", line 593, in acquireconnection
    self.__authn_helper(imapobj)
  File "/usr/share/offlineimap3/offlineimap/imapserver.py", line 453, in __authn_helper
    raise OfflineImapError("All authentication types "

In .offlineimaprc:

[general]
accounts = support@domainA.tld


[Account support@domainA.tld]
localrepository = Local_support@domainA.tld
remoterepository = Remote_support@domainA.tld

[Repository Local_support@domainA.tld]
type = IMAP
ssl = false
remotehost = localhost
remoteuser = support@domainA.tld
remotepass = xxxxxxxxxxx


[Repository Remote_support@domainA.tld]
type = IMAP
remotehost = mailhub.xxxxxxx.eu
remoteport = 993

ssl = yes
sslcacertfile = /etc/ssl/certs/ca-certificates.crt

remoteuser = support@domainA.tld
remotepass = xxxxxxxxxxx
readonly = true

If I understand how it works, it seems that the "Local_support@domainA.tld" should be "Local_support@domainB.tld. That's why the authentication doesn't work.

<!-- gh-comment-id:1256404469 --> @stefaweb commented on GitHub (Sep 23, 2022): Hi! I finally finished the setup. Working now. ``` python manage.py makemigrations python manage.py migrate modoboa_imap_migration ``` It seems that transforming the address of a domain is not working. Old server: user1@domainA.tld New server: user1@domainB.tld In the new server: domainB.tld Associated domains domainA.tld -> domainB.tld The sync do not work (WRONG AUTH). If we don't use it. It works with the same accounts/domains. ``` root@mailhub:/srv/vmail# sudo -u vmail -i $ cd /srv/vmail && /srv/modoboa/env/bin/python /srv/modoboa/instance/manage.py generate_offlineimap_config --output .offlineimaprc && /usr/bin/offlineimap OfflineIMAP 8.0.0 Licensed under the GNU GPL v2 or any later version (with an OpenSSL exception) imaplib2 v3.05, Python v3.9.2, OpenSSL 1.1.1n 15 Mar 2022 Account sync sleclerc@domainA.tld: *** Processing account support@adomainA.tld Establishing connection to mailhub.xxxxxxx.eu:993 (Remote_support@domainA.tld) Establishing connection to localhost:143 (Local_support@domainA.tld) PLAIN authentication failed: b'[AUTHENTICATIONFAILED] Authentication failed.' LOGIN authentication failed: b'[AUTHENTICATIONFAILED] Authentication failed.' ERROR: All authentication types failed: PLAIN: b'[AUTHENTICATIONFAILED] Authentication failed.' LOGIN: b'[AUTHENTICATIONFAILED] Authentication failed.' *** Finished account 'support@domainA.tld' in 0:08 ERROR: Exceptions occurred during the run! ERROR: All authentication types failed: PLAIN: b'[AUTHENTICATIONFAILED] Authentication failed.' LOGIN: b'[AUTHENTICATIONFAILED] Authentication failed.' Traceback: File "/usr/share/offlineimap3/offlineimap/accounts.py", line 298, in syncrunner self.__sync() File "/usr/share/offlineimap3/offlineimap/accounts.py", line 375, in __sync localrepos.getfolders() File "/usr/share/offlineimap3/offlineimap/repository/IMAP.py", line 681, in getfolders imapobj = self.imapserver.acquireconnection() File "/usr/share/offlineimap3/offlineimap/imapserver.py", line 593, in acquireconnection self.__authn_helper(imapobj) File "/usr/share/offlineimap3/offlineimap/imapserver.py", line 453, in __authn_helper raise OfflineImapError("All authentication types " ``` In .offlineimaprc: ``` [general] accounts = support@domainA.tld [Account support@domainA.tld] localrepository = Local_support@domainA.tld remoterepository = Remote_support@domainA.tld [Repository Local_support@domainA.tld] type = IMAP ssl = false remotehost = localhost remoteuser = support@domainA.tld remotepass = xxxxxxxxxxx [Repository Remote_support@domainA.tld] type = IMAP remotehost = mailhub.xxxxxxx.eu remoteport = 993 ssl = yes sslcacertfile = /etc/ssl/certs/ca-certificates.crt remoteuser = support@domainA.tld remotepass = xxxxxxxxxxx readonly = true ``` If I understand how it works, it seems that the "Local_support@domainA.tld" should be "Local_support@domainB.tld. That's why the authentication doesn't work.
Author
Owner

@stefaweb commented on GitHub (Sep 23, 2022):

When we load the migration page in GUIv1, we have these two files called but missing.

Failed to load resource: the server responded with a status of 404 (Not Found)

https://mail.aweb.fr/sitestatic/modoboa_imap_migration/js/chunk-vendors.5f20a268.js.map

https://mail.aweb.fr/sitestatic/modoboa_imap_migration/js/chunk-vendors.5f20a268.js.map

<!-- gh-comment-id:1256584652 --> @stefaweb commented on GitHub (Sep 23, 2022): When we load the migration page in GUIv1, we have these two files called but missing. ``` Failed to load resource: the server responded with a status of 404 (Not Found) https://mail.aweb.fr/sitestatic/modoboa_imap_migration/js/chunk-vendors.5f20a268.js.map https://mail.aweb.fr/sitestatic/modoboa_imap_migration/js/chunk-vendors.5f20a268.js.map ```
Author
Owner

@stefaweb commented on GitHub (Sep 26, 2022):

hi!

I tried the domain transcoding feature again. It doesn't want to work.

I found another point.

In the /srv/vmail/.offlineimaprc file, we have sslcacertfile def.

Where does this definition come from?

sslcacertfile = /etc/ssl/certs/ca-certificates.crt

As I use Letsencrypt certbot, I thought I would find the path to the Letsencryp certificate there.

sslcacertfile = /etc/letsencrypt/live/...

<!-- gh-comment-id:1258043494 --> @stefaweb commented on GitHub (Sep 26, 2022): hi! I tried the domain transcoding feature again. It doesn't want to work. I found another point. In the /srv/vmail/.offlineimaprc file, we have sslcacertfile def. Where does this definition come from? ``` sslcacertfile = /etc/ssl/certs/ca-certificates.crt ``` As I use Letsencrypt certbot, I thought I would find the path to the Letsencryp certificate there. `sslcacertfile = /etc/letsencrypt/live/...`
Author
Owner

@stefaweb commented on GitHub (Sep 27, 2022):

I am closing this issue to open a new, more specific one.

<!-- gh-comment-id:1259069409 --> @stefaweb commented on GitHub (Sep 27, 2022): I am closing this issue to open a new, more specific one.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/modoboa-modoboa#1654
No description provided.