Users.role_id and usergroups.auth_source_id mysql to postgres migration

Problem:

Migrating Mysql to Postgresql at version 1.24 results in errors for a number of tables.

In particular mysql instance contains the following columns which are not present
in the fresh postgres schema so migration fails.

  • architectures_operatingsystems.created_at

  • bookmarks.created_at

  • media_operatingsystems.created_at

  • operatingsystems_provisioning_templates.created_at

  • operatingsystems_ptables.created_at

  • roles drop.created_at

  • smart_proxy_features.created_at

  • user_roles drop.created_at

  • usergroup_members.created_at

  • users drop column role_id ;

  • usergroups.auth_source_id ;

Expected outcome:

If should migrate to postgres okay.

Foreman and Proxy versions:
Migration is at 1.24 but we are in fact migrating from 1.11 to 2.4

The created_at columns are not really a worry as I can just drop those columns
before migration.

The last two seem more important. Maybe I should create these columns in postgres first ? We certainly do have roles attached to users.

Possibly some relation to - Bug #32466: Foreman login delegation and usergroup membership - Foreman for the last one.

Did you upgrade in one step from 1.11 to 1.24?
It seems like one of the migrations did not run properly on your database:

db/migrations/20130924145800_remove_unused_role_fields.rb

I didn’t manage to find where all these created_at fields were added - but they can indeed be safely removed.
The same goes for usergroups.auth_source_id - as far as i can tell this field never existed, at least in foreman core migrations. before dropping this one you might want to check if it contains any values.