rmens
15 أبريل 2021، 7:32م
1
Hi guys,
Today I had an unusual request after a migration where we skipped all accounts that never posted.
A user that had never posted, but values having an account, wanted his account back. I told him he could just re-register with his old username which he did. But now he wants to have his ‘member since’ adjusted to 2011, when he registered his old account…
Is there any way I can accomplish this?
By ‘member since’ do you mean the Joined section in your account summary?
If you have admin access to the server or database, you could edit the created_at parameter for that user in the Users table.
You can do it from the rails console this way:
rails c
user = User.where(username: '<your-username-here>')
user.update(created_at: "2011-02-10 00:00:00.00000")
You could also do it directly in the Postgre database (although I don’t recommend it):
update public.users set created_at='2011-02-10 00:00:00.00000' where username = '<your-username-here>';
I tested this in my local environment and worked correctly:
Changed from:
To:
Please be very careful if you decide to go with this, I suggest you take a backup of the database before doing anything
9 إعجابات
rmens
17 أبريل 2021، 10:06ص
3
Thanks a lot. That was the parameter I needed to change.
3 إعجابات
system
(system)
تم إغلاقه في
17 مايو 2021، 10:07ص
4
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.