Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ckan db upgrade fixes #7681

Merged
merged 5 commits into from
Jul 25, 2023
Merged

ckan db upgrade fixes #7681

merged 5 commits into from
Jul 25, 2023

Conversation

amercader
Copy link
Member

I'm working on an upgrade from CKAN 2.5 to 2.10 and found errors that can be solved at the CKAN level

The most potentially controversial is the first commit (8d0d3b3). Basically when calling the magic get_site_user action when starting up ckan db upgrade we get an error because the python model defines User.last_active and that is not present in the database (was introduced on CKAN 2.10). I've followed the same approach that we do to avoid race conditions on that particular situation and added an exception handling.

The rest of changes related to the separate script used to migrate the old revisions to activities and should be hopefully self-explanatory:

I think anything that makes life easier for those trying to upgrade it's a good think, so I'm proposing to backport this

User.last_active was introduced in CKAN 2.10. When trying to run `ckan
db ugprade` against a database that was created before that you get the
following error:

    sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedColumn) column user.last_active does not exist
    LINE 1: ...ey AS user_reset_key, "user".about AS user_about,
     "user".las..

This is caused by the `get_site_user` action call that we do on
`update_config()`. The changes detect this error and continue the
execution, similarly to how we check about a potential race condition.
Otherwise you get an `package_activity_list` action not found error
The ordering changes doesn't seem to affect the actual migration from
revisions to activities, it was just copied verbatim from the old VDM
code
@smotornyuk smotornyuk self-assigned this Jun 29, 2023
@amercader
Copy link
Member Author

Unrelated failures fixed now

note: changes in environment.py don't apply to 2.10 and 2.9

@smotornyuk smotornyuk merged commit 31333cb into master Jul 25, 2023
@smotornyuk smotornyuk deleted the db-migration-fixes branch July 25, 2023 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants