modoboa / modoboa-imap-migration

An extension to ease the migration between 2 IMAP servers using offlineimap
ISC License
16 stars 12 forks source link

Unable to install plugin with modoboa 2.0.1 #122

Closed stefaweb closed 2 years ago

stefaweb commented 2 years ago

Unable to install plugin with modoboa 2.0.1

Impacted versions

Steps to reproduce

Current behavior

Hello!

I tried to install the plugin but it crashes. Since I haven't done this for years, I don't know if this is a bug or an installation error on my part.

Here is what works:

root@mailhub:/home# sudo -u modoboa -i
$ bash
modoboa@mailhub:~$ . /srv/modoboa/env/bin/activate
(env) modoboa@mailhub:~$ pip install modoboa-imap-migration==1.4.1
Requirement already satisfied: modoboa-imap-migration==1.4.1 in ./env/lib/python3.9/site-packages (1.4.1)
Requirement already satisfied: modoboa>=2.0.0 in ./env/lib/python3.9/site-packages (from modoboa-imap-migration==1.4.1) (2.0.1)
Requirement already satisfied: django-webpack-loader in ./env/lib/python3.9/site-packages (from modoboa-imap-migration==1.4.1) (0.7.0)
Requirement already satisfied: qrcode in ./env/lib/python3.9/site-packages (from modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (7.3.1)
Requirement already satisfied: rrdtool>=0.1.10 in ./env/lib/python3.9/site-packages (from modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (0.1.16)
Requirement already satisfied: dnspython==2.2.1 in ./env/lib/python3.9/site-packages (from modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (2.2.1)
Requirement already satisfied: pytz in ./env/lib/python3.9/site-packages (from modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (2022.2.1)
Requirement already satisfied: gevent==21.12.0 in ./env/lib/python3.9/site-packages (from modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (21.12.0)
Requirement already satisfied: requests in ./env/lib/python3.9/site-packages (from modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (2.28.1)
Requirement already satisfied: py-dateutil==2.2 in ./env/lib/python3.9/site-packages (from modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (2.2)
Requirement already satisfied: progressbar33==2.4 in ./env/lib/python3.9/site-packages (from modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (2.4)
Requirement already satisfied: passlib~=1.7.4 in ./env/lib/python3.9/site-packages (from modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (1.7.4)
Requirement already satisfied: drf-spectacular in ./env/lib/python3.9/site-packages (from modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (0.24.0)
Requirement already satisfied: django-reversion==5.0.0 in ./env/lib/python3.9/site-packages (from modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (5.0.0)
Requirement already satisfied: django<4.0 in ./env/lib/python3.9/site-packages (from modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (3.2.15)
Requirement already satisfied: dj-database-url in ./env/lib/python3.9/site-packages (from modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (1.0.0)
Requirement already satisfied: uritemplate in ./env/lib/python3.9/site-packages (from modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (4.1.1)
Requirement already satisfied: chardet in ./env/lib/python3.9/site-packages (from modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (5.0.0)
Requirement already satisfied: ovh in ./env/lib/python3.9/site-packages (from modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (1.0.0)
Requirement already satisfied: aiosmtplib in ./env/lib/python3.9/site-packages (from modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (1.1.7)
Requirement already satisfied: djangorestframework-simplejwt==5.1.0 in ./env/lib/python3.9/site-packages (from modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (5.1.0)
Requirement already satisfied: lxml in ./env/lib/python3.9/site-packages (from modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (4.9.1)
Requirement already satisfied: django-xforwardedfor-middleware==2.0 in ./env/lib/python3.9/site-packages (from modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (2.0)
Requirement already satisfied: django-otp==1.1.3 in ./env/lib/python3.9/site-packages (from modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (1.1.3)
Requirement already satisfied: oath in ./env/lib/python3.9/site-packages (from modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (1.4.4)
Requirement already satisfied: asgiref in ./env/lib/python3.9/site-packages (from modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (3.5.2)
Requirement already satisfied: jsonfield==3.1.0 in ./env/lib/python3.9/site-packages (from modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (3.1.0)
Requirement already satisfied: aioredis==2.0.1 in ./env/lib/python3.9/site-packages (from modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (2.0.1)
Requirement already satisfied: django-phonenumber-field[phonenumbers]==6.1.0 in ./env/lib/python3.9/site-packages (from modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (6.1.0)
Requirement already satisfied: feedparser==6.0.8 in ./env/lib/python3.9/site-packages (from modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (6.0.8)
Requirement already satisfied: django-filter in ./env/lib/python3.9/site-packages (from modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (21.1)
Requirement already satisfied: redis in ./env/lib/python3.9/site-packages (from modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (4.3.4)
Requirement already satisfied: djangorestframework<3.14,>=3.11 in ./env/lib/python3.9/site-packages (from modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (3.13.1)
Requirement already satisfied: cryptography in ./env/lib/python3.9/site-packages (from modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (38.0.1)
Requirement already satisfied: Pillow in ./env/lib/python3.9/site-packages (from modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (9.2.0)
Requirement already satisfied: bcrypt in ./env/lib/python3.9/site-packages (from modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (4.0.0)
Requirement already satisfied: django-ckeditor==6.3.0 in ./env/lib/python3.9/site-packages (from modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (6.3.0)
Requirement already satisfied: greenlet==1.1.2 in ./env/lib/python3.9/site-packages (from modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (1.1.2)
Requirement already satisfied: typing-extensions in ./env/lib/python3.9/site-packages (from aioredis==2.0.1->modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (4.3.0)
Requirement already satisfied: async-timeout in ./env/lib/python3.9/site-packages (from aioredis==2.0.1->modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (4.0.2)
Requirement already satisfied: django-js-asset>=1.2.2 in ./env/lib/python3.9/site-packages (from django-ckeditor==6.3.0->modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (2.0.0)
Requirement already satisfied: phonenumbers>=7.0.2 in ./env/lib/python3.9/site-packages (from django-phonenumber-field[phonenumbers]==6.1.0->modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (8.12.55)
Requirement already satisfied: pyjwt<3,>=1.7.1 in ./env/lib/python3.9/site-packages (from djangorestframework-simplejwt==5.1.0->modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (2.5.0)
Requirement already satisfied: sgmllib3k in ./env/lib/python3.9/site-packages (from feedparser==6.0.8->modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (1.0.0)
Requirement already satisfied: setuptools in ./env/lib/python3.9/site-packages (from gevent==21.12.0->modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (57.5.0)
Requirement already satisfied: zope.event in ./env/lib/python3.9/site-packages (from gevent==21.12.0->modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (4.5.0)
Requirement already satisfied: zope.interface in ./env/lib/python3.9/site-packages (from gevent==21.12.0->modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (5.4.0)
Requirement already satisfied: six in ./env/lib/python3.9/site-packages (from py-dateutil==2.2->modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (1.16.0)
Requirement already satisfied: sqlparse>=0.2.2 in ./env/lib/python3.9/site-packages (from django<4.0->modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (0.4.2)
Requirement already satisfied: cffi>=1.12 in ./env/lib/python3.9/site-packages (from cryptography->modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (1.15.1)
Requirement already satisfied: PyYAML>=5.1 in ./env/lib/python3.9/site-packages (from drf-spectacular->modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (6.0)
Requirement already satisfied: jsonschema>=2.6.0 in ./env/lib/python3.9/site-packages (from drf-spectacular->modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (4.16.0)
Requirement already satisfied: inflection>=0.3.1 in ./env/lib/python3.9/site-packages (from drf-spectacular->modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (0.5.1)
Requirement already satisfied: charset-normalizer<3,>=2 in ./env/lib/python3.9/site-packages (from requests->modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (2.1.1)
Requirement already satisfied: idna<4,>=2.5 in ./env/lib/python3.9/site-packages (from requests->modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (3.4)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in ./env/lib/python3.9/site-packages (from requests->modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (1.26.12)
Requirement already satisfied: certifi>=2017.4.17 in ./env/lib/python3.9/site-packages (from requests->modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (2022.9.14)
Requirement already satisfied: packaging>=20.4 in ./env/lib/python3.9/site-packages (from redis->modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (21.3)
Requirement already satisfied: deprecated>=1.2.3 in ./env/lib/python3.9/site-packages (from redis->modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (1.2.13)
Requirement already satisfied: pycparser in ./env/lib/python3.9/site-packages (from cffi>=1.12->cryptography->modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (2.21)
Requirement already satisfied: wrapt<2,>=1.10 in ./env/lib/python3.9/site-packages (from deprecated>=1.2.3->redis->modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (1.14.1)
Requirement already satisfied: attrs>=17.4.0 in ./env/lib/python3.9/site-packages (from jsonschema>=2.6.0->drf-spectacular->modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (22.1.0)
Requirement already satisfied: pyrsistent!=0.17.0,!=0.17.1,!=0.17.2,>=0.14.0 in ./env/lib/python3.9/site-packages (from jsonschema>=2.6.0->drf-spectacular->modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (0.18.1)
Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in ./env/lib/python3.9/site-packages (from packaging>=20.4->redis->modoboa>=2.0.0->modoboa-imap-migration==1.4.1) (3.0.9)
(env) modoboa@mailhub:~$ cd instance
(env) modoboa@mailhub:~/instance$ python manage.py migrate
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:~/instance$ python manage.py migrate modoboa_imap_migration
Operations to perform:
  Apply all migrations: modoboa_imap_migration
Running migrations:
  Applying modoboa_imap_migration.0001_initial... OK
  Applying modoboa_imap_migration.0002_password... OK
  Applying modoboa_imap_migration.0003_auto_20190207_0919... OK
  Applying modoboa_imap_migration.0004_auto_20190207_0939... OK
  Applying modoboa_imap_migration.0005_auto_20210401_0938... OK
(env) modoboa@mailhub:~/instance$ python manage.py load_initial_data
Unable to load initial data for 'modoboa_amavis' (Policy matching query does not exist.).
stefaweb commented 2 years ago

I close this issue.

I used old installation process and forgot to install "apt-get install python3-virtualenv python3-pip".