Skip to content

[bug]: db migration issue when updating from stable (v0.14.0) to stable (v0.21.0) #4988

@c3JpbmkK

Description

@c3JpbmkK

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

We have a self-hosted Plane instance (it was deployed on January by a colleague) that was untouched for a while and I tried to upgrade it to the latest version recently and ended up crashing the instance for several reasons. The only real issue was the migrator service crashing and the other services were waiting for DB to become available.

Error message

Waiting for database...
Database available!
Operations to perform:
  Apply all migrations: auth, contenttypes, db, django_celery_beat, license, sessions
Running migrations:
  Applying db.0051_cycle_external_id_cycle_external_source_and_more... OK
  Applying db.0052_auto_20231220_1141... OK
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/psycopg/cursor.py", line 732, in execute
    raise ex.with_traceback(None)
psycopg.errors.UndefinedTable: relation "workspace_user_properties" does not exist
LINE 1: INSERT INTO "workspace_user_properties" ("created_at", "upda...

When I inspected the DB I found the table was called "Workspace_user_properties", so I was able to workaround the issue by renaming the table and get the service running again. Later on, it had another issue where it was expecting the table to be called "workspace_user_properties". I renamed the table again and the rest of the migrations were completed

Used workaround:

# Other services are waiting for db
# First migration fail at Applying db.0053_auto_20240102_1315
$ docker exec -it plane-app-plane-db-1 psql -Uplane -c 'alter table "Workspace_user_properties" rename to "workspace_user_properties"'
Password for user plane:
ALTER TABLE
$ docker restart plane-app-migrator-1
# Second migration fail at Applying db.0065_auto_20240415_0937
$ docker exec -it plane-app-plane-db-1 psql -Uplane -c 'alter table "workspace_user_properties" rename to "Workspace_user_properties"'
Password for user plane:
ALTER TABLE
$ docker restart plane-app-migrator-1
# Restart all services using setup.sh after migrator is done

Questions:

  1. Is this workaround safe that I could proceed with future updates without any manual intervention on the DB again, or does it pose possible issues in the future ?
  2. Is this migration error actually an issue ? I couldnt find any mention of it in this repo but I did find mentions of it in other places (python and django related)

Steps to reproduce

Not really sure if the bug could be reproduced or if its even a bug, our instance was not very active and it was unmaintained till recently

Steps

  1. Have a self-hosted plane instance at v0.14.0
  2. Upgrade the instance to latest stable release (v0.21.0) using setup.sh upgrade option (either using the setup.sh from v0.14.0 or a newer setup.sh from stable)
  3. Watch the migrator service fail with the error message from above

Environment

Production

Browser

None

Variant

Self-hosted

Version

v0.14.0

Metadata

Metadata

Labels

🐛bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions