Problem with upgrade/migration from 5.0 to 5.2

I am not sure what I did wrong.

I am getting an error on connect from client to server:

Traceback (most recent call last):
  File "/trytond/wsgi.py", line 104, in dispatch_request
    return endpoint(request, **request.view_args)
  File "/trytond/protocols/dispatcher.py", line 48, in rpc
    request, database_name, *request.rpc_params)
  File "/trytond/wsgi.py", line 72, in auth_required
    return wrapped(*args, **kwargs)
  File "/trytond/protocols/wrappers.py", line 131, in wrapper
    return func(request, pool, *args, **kwargs)
  File "/trytond/protocols/dispatcher.py", line 186, in _dispatch
    result = rpc.result(meth(*c_args, **c_kwargs))
  File "/trytond/res/user.py", line 503, in get_preferences
    preferences = cls._get_preferences(user, context_only=context_only)
  File "/trytond/modules/company_work_time/res.py", line 15, in _get_preferences
    context_only=context_only)
  File "/trytond/modules/company/company.py", line 191, in _get_preferences
    context_only=context_only)
  File "/trytond/res/user.py", line 466, in _get_preferences
    getattr(user, field).rec_name
  File "/trytond/model/fields/field.py", line 332, in __get__
    return inst.__getattr__(self.name)
  File "/trytond/model/modelstorage.py", line 1525, in __getattr__
    read_data = self.read(list(ids), list(ffields.keys()))
  File "/trytond/model/modelsql.py", line 832, in read
    getter_results = field.get(ids, cls, field_list, values=result)
  File "/trytond/model/fields/function.py", line 106, in get
    return dict((name, call(name)) for name in names)
  File "/trytond/model/fields/function.py", line 106, in <genexpr>
    return dict((name, call(name)) for name in names)
  File "/trytond/model/fields/function.py", line 101, in call
    return dict((r.id, method(r, name)) for r in records)
  File "/trytond/model/fields/function.py", line 101, in <genexpr>
    return dict((r.id, method(r, name)) for r in records)
  File "/trytond/model/modelstorage.py", line 570, in get_rec_name
    return str(getattr(self, rec_name))
  File "/trytond/model/fields/field.py", line 332, in __get__
    return inst.__getattr__(self.name)
  File "/trytond/model/modelstorage.py", line 1525, in __getattr__
    read_data = self.read(list(ids), list(ffields.keys()))
  File "/trytond/model/modelsql.py", line 756, in read
    order_by=history_order, limit=history_limit))
  File "/trytond/backend/postgresql/database.py", line 67, in execute
    cursor.execute(self, sql, args)
psycopg2.errors.UndefinedColumn: column c.active does not exist
LINE 1: ... 23, 27, 29, 28, 21, 22, 31, 10, 9, 11, 13)) AND ("c"."activ...
                                                             ^
HINT:  Perhaps you meant to reference the column "a.active".


Fault: column c.active does not exist
LINE 1: ... 23, 27, 29, 28, 21, 22, 31, 10, 9, 11, 13)) AND ("c"."activ...
                                                             ^
HINT:  Perhaps you meant to reference the column "a.active".

Did you update the database as explained in How to setup a database — trytond 5.3 documentation and follow the migration steps from Migration from 5.0 to 5.2 ?

Hi Cedric,

Thank you for the quick reply.

Yes I did.

I did them again just to be sure.

The migration step resulted in 0 rows affected and the constraints do not exist messages.

trytond-admin -c trytond-admin.conf tryton --all

resulted in the following both times. However, in the past I think these were ignorable messages.

I had got this:
3198 139701140494144 [2019-06-09 11:39:13,207] ERROR trytond.convert Could not delete id: 11 of model res.user
There should be some relation that points to this resource
You should manually fix this and restart --update=module
Traceback (most recent call last):
File “/usr/local/lib/python3.6/dist-packages/trytond/convert.py”, line 806, in post_import
Model.delete([Model(db_id)])
File “/usr/local/lib/python3.6/dist-packages/trytond/res/user.py”, line 408, in delete
raise DeleteError(gettext(‘res.msg_user_delete_forbidden’))
trytond.res.user.DeleteError: (‘UserError’, (‘For logging purposes users cannot be deleted, instead they should be deactivated.’, ‘’))
3198 139701140494144 [2019-06-09 11:39:13,309] ERROR trytond.convert Could not delete id: 10 of model res.user
There should be some relation that points to this resource

several such messages with different ID’s

Thanks

Paul

So you need to investigate to find which table is missing the active column and why it is not created by the update.

OK. Where do I start?

You should investigate which table is missing the active column. A good idea is to start the server with the more versbose option (use -vvvv parameter) so it will print the queries and you will know which one is failing.

At first, I would try to get the full SQL query that is failing by putting a print statement where it is failing. This way we could know which table does not seem to be up to date.

So this was user error. I had a second database that was not upgraded and the client was pointing to that instead of the upgraded db.