-
Stan Hu authored
Some database schemas have `members.created_at` set as `timestamp with time zone`, while on GitLab.com and dev we have `timestamp without time zone`. If the column has a time zone, the `OrphanedInviteTokensCleanup` migration fails with the following error: ``` PG::InvalidObjectDefinition: ERROR: functions in index predicate must be marked IMMUTABLE ``` As described in https://stackoverflow.com/a/58848792, if the time zone depends on the server, the result might change if somebody changes the time zone. We need to lock the time zone if the timezone depends on the server. We need to make sure the comparison between `created_at` and `invite_accepted_at` are done using the same types or PostgreSQL will reject the query due to immutability concerns. Calling `TIMEZONE('UTC', column)` on a `timestamp without time zone` converts it to `timestamp with time zone` type. Calling the same function on a `timestamp with time zone` converts it to a type of `timestamp without time zone`. Therefore, we should check the type before we do this conversion. There is an epic that deals with reconciling these datetime with timezone differences: https://gitlab.com/groups/gitlab-org/-/epics/2473 Relates to https://gitlab.com/gitlab-org/gitlab/-/issues/339091 Changelog: fixed
affc79c6