taigaio / taiga-back

Mozilla Public License 2.0
598 stars 172 forks source link

[BUG] Migration Error #103

Open mzch opened 2 years ago

mzch commented 2 years ago

Describe the bug

When running DJANGO_SETTINGS_MODULE=settings.config python manage.py migrate --noinput, the following error occurred. This seems to happen using PostgreSQL 14 or later. Ref. mailing list article

Running migrations:
  Applying projects.0046_triggers_to_update_tags_colors...Traceback (most recent call last):
  File "/srv/taiga/.pyenv/versions/3.7.13/lib/python3.7/site-packages/django/db/backends/utils.py", line 82, in _execute
    return self.cursor.execute(sql)
psycopg2.errors.UndefinedFunction: function array_cat(anyarray, anyarray) does not exist

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

Traceback (most recent call last):
  File "manage.py", line 17, in <module>
    execute_from_command_line(sys.argv)
  File "/srv/taiga/.pyenv/versions/3.7.13/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/srv/taiga/.pyenv/versions/3.7.13/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/srv/taiga/.pyenv/versions/3.7.13/lib/python3.7/site-packages/django/core/management/base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/srv/taiga/.pyenv/versions/3.7.13/lib/python3.7/site-packages/django/core/management/base.py", line 364, in execute
    output = self.handle(*args, **options)
  File "/srv/taiga/.pyenv/versions/3.7.13/lib/python3.7/site-packages/django/core/management/base.py", line 83, in wrapped
    res = handle_func(*args, **kwargs)
  File "/srv/taiga/.pyenv/versions/3.7.13/lib/python3.7/site-packages/django/core/management/commands/migrate.py", line 234, in handle
    fake_initial=fake_initial,
  File "/srv/taiga/.pyenv/versions/3.7.13/lib/python3.7/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/taiga/.pyenv/versions/3.7.13/lib/python3.7/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/taiga/.pyenv/versions/3.7.13/lib/python3.7/site-packages/django/db/migrations/executor.py", line 245, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/srv/taiga/.pyenv/versions/3.7.13/lib/python3.7/site-packages/django/db/migrations/migration.py", line 124, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/srv/taiga/.pyenv/versions/3.7.13/lib/python3.7/site-packages/django/db/migrations/operations/special.py", line 105, in database_forwards
    self._run_sql(schema_editor, self.sql)
  File "/srv/taiga/.pyenv/versions/3.7.13/lib/python3.7/site-packages/django/db/migrations/operations/special.py", line 130, in _run_sql
    schema_editor.execute(statement, params=None)
  File "/srv/taiga/.pyenv/versions/3.7.13/lib/python3.7/site-packages/django/db/backends/base/schema.py", line 137, in execute
    cursor.execute(sql, params)
  File "/srv/taiga/.pyenv/versions/3.7.13/lib/python3.7/site-packages/raven/contrib/django/client.py", line 127, in execute
    return real_execute(self, sql, params)
  File "/srv/taiga/.pyenv/versions/3.7.13/lib/python3.7/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/srv/taiga/.pyenv/versions/3.7.13/lib/python3.7/site-packages/django/db/backends/utils.py", line 76, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/srv/taiga/.pyenv/versions/3.7.13/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/srv/taiga/.pyenv/versions/3.7.13/lib/python3.7/site-packages/django/db/utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/srv/taiga/.pyenv/versions/3.7.13/lib/python3.7/site-packages/django/db/backends/utils.py", line 82, in _execute
    return self.cursor.execute(sql)
django.db.utils.ProgrammingError: function array_cat(anyarray, anyarray) does not exist

How can we reproduce the behavior

Run DJANGO_SETTINGS_MODULE=settings.config python manage.py migrate --noinput

Workarounds

Screenshots

None.

Taiga environment

Additional context

giorgi17 commented 1 year ago

Same error, not working!

giorgi17 commented 1 year ago

On Tue, 21 Feb 2023 at 20:23, Maxime @.***> wrote:

I'm facing the same error, did you find a solution?

— Reply to this email directly, view it on GitHub https://github.com/kaleidos-ventures/taiga-back/issues/103#issuecomment-1438761361, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFBHFNCYID34W4GP4T5PYSTWYTTX7ANCNFSM55XZO6CQ . You are receiving this because you commented.Message ID: @.***>

Nope, i switched to Redmine instead

fady-shafeek commented 1 year ago

facing the same error, did you find a solution?

giorgi17 commented 1 year ago

No, I didn't.

On Fri, 10 Mar 2023 at 03:03, Fady Shafeek @.***> wrote:

facing the same error, did you find a solution?

— Reply to this email directly, view it on GitHub https://github.com/kaleidos-ventures/taiga-back/issues/103#issuecomment-1462945134, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFBHFNEB7OJVYRAZQQ7E2P3W3JOVXANCNFSM55XZO6CQ . You are receiving this because you commented.Message ID: @.***>

FelipeSo commented 1 year ago

I solved it using a docker container for the postgres database and changing the database port in the /settings/common.py file as showed below.

I added a docker-compose file in the root folder (above taiga-back) (I don't know if the location matters but worth mention) The docker-compose.yml :

version: '3.5'

services:
  taiga-db-2:
    container_name: taiga-db-2
    image: postgres:12.3
    restart: always
    environment:
      POSTGRES_DB: taiga
      POSTGRES_USER: taiga
      POSTGRES_PASSWORD: taiga
    ports:
      - "5433:5432"
    volumes:
      - taiga-db-data-2:/var/lib/posrgresql/data
volumes:
  taiga-db-data-2:

Then did docker compose up to run the container

Is worth mention that i ran this code: sudo netstat -nl | grep postgres to check in what port was postgres running, and it showed that it was running in port 5432

I had the database port configured like this, to work with the port that I thought was the appropiate:

DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.postgresql",
        "NAME": "taiga",
        "USER": "taiga",
        "PASSWORD": "taiga",
        "HOST": "127.0.0.1",
        'PORT': '5432'
    }
}

Then I changed the port to 5433 and it works (when the docker container from above is running):

DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.postgresql",
        "NAME": "taiga",
        "USER": "taiga",
        "PASSWORD": "taiga",
        "HOST": "127.0.0.1",
        'PORT': '5433'
    }
}

After this changes the migration ran without error