カスタムユーザーフィールドを復元できますか?

カスタムユーザーフィールドを誤って削除してしまいました。これはデータベースから完全に削除されたということでしょうか、それともまだ残っているのでしょうか?

もし残っている場合、バックアップを復元する以外に、取り消す方法やデータエクスプローラーを通じて内容にアクセスする方法はありますか?

I’m 95% sure a deleted custom field is gone forever.

If you can’t see it in data explorer, it’s not there anymore.

「いいね!」 3

Just a thought, but surely there would be a way to recreate the Custom Field and hack together a script to retrieve and refill the data from within a backup using a temporary cloud server to write out the data from the original Custom Field?

Thanks for your thoughts. Yes, that’s obviously what backups are for. I don’t know what the smartest procedure would be for restoring user field content for, say, thousands of users. For me, the number the easiest procedure was to just do it manually. And that was actually surprisingly easy, so I mention it here (from memory, so I may have missed some detail):

  • When you download the backup file and open it for example with good old WinRAR, you’ll find another archive in there, so open that with WinRAR too. You’ll find an .sql file.
  • And now comes the good part: you can just open it as a text file (with the built-in WinRAR viewer or otherwise).
  • Search for the name of the field or some content you hapoen to know and you’ll find the table for that user field.
  • Now the only trickyness is that (at least in my case) the user ID is not the first but the second value in each row (I’d be curious what the first value represents (“COPY”)).
「いいね!」 2

現在、カスタムフィールド(field_typedropdown の場合、user_fields および user_fields_options テーブル)を削除しても、ユーザーの実際の値(user_custom_fields テーブル)は削除されません。そのため、簡易的(ただし潜在的に危険:必ずバックアップを取得してください)な回避策として、以下の手順を実行できます。

  1. 新しいカスタムフィールドを手動で作成する
  2. 新しい user_fields の ID を古い ID に置き換える(これにはデータベースへの管理者アクセスが必要):UPDATE user_fields SET id=1 WHERE id=3;(3 が新しい ID、1 が古い ID と仮定)
  3. フィールドがドロップダウンだった場合、user_field_options についても同様の処理を行う必要がある
  4. 修正前にサイトに登録し、新しいフィールドに入力したユーザーがいたり(または既存のユーザーが新しいフィールドに入力していた場合)、それらのデータも修正する必要がある
「いいね!」 2