Вопрос

I'm new to rails and have just had my first bad experience with the mighty rails console. I overwrote a column in ALL instead of just one record and after hours of googling I did not find a common way to rollback this stupid transaction (ended up fixing 76 rows manually!).

I was working on the live environment on heroku and just wanted to fix one entry. There must be a way to rollback a transaction in the database (postgres) if you did stupid things - not by using pgbackup.

Would be great if you can share some best pratices with me or give me a good reading to start. Thanks!

Это было полезно?

Решение

I'm assuming you've already committed the transaction, but just in case you haven't, you can simply do:

ROLLBACK TRANSACTION;

Since I'm assuming you've tried that, the unfortunate answer is that your only option is a database restore from the last known good state.

There are some options and plugins that might help avoid this problem in the future, but they all come with performance costs. See these other Stack Overflow questions for some information Database Content Versioning and Postgres reverting back.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top