What are the differences between ‘revert’, ‘amend,’ ‘rollback’, and ‘undo’ a commit?

The terms revert and amend have a well defined meaning in Git. In contrast, rollback and undo do not have such a well defined meaning, and are open to interpretation. Reverting a commit… …means creating (on the current branch) a new commit that applies the inverse changes that another commit introduced. It’s the preferred approach … Read more

Rake db:migrate – how do I undo all migrations and redo them

Rolling back all migrations To rollback all migrations the best solution is the one @Claudio Floreani proposed: rake db:migrate VERSION=0 This will rollback every migration. You can read why this is the best approach in his answer. Then, run all migrations again with rake db:migrate Resetting the database Reset rake db:migrate:reset #runs db:drop db:create db:migrate … Read more

Git rollback 1 pull

git reset –hard HEAD^1 will take you back one commit from what you pulled. If you want it back to the state it was in before you pulled, use git reset –hard HEAD@{1}. The @{1} tracks where the head was at before the last operation that changed it in your local repo, so it will … Read more

How to roll back migrations using Flyway?

While Flyway supports rollbacks (as a commercial-only feature) its use is discouraged: https://flywaydb.org/documentation/command/undo While the idea of undo migrations is nice, unfortunately it sometimes breaks down in practice. As soon as you have destructive changes (drop, delete, truncate, …), you start getting into trouble. And even if you don’t, you end up creating home-made alternatives … Read more

ActiveRecord::StatementInvalid: PG InFailedSqlTransaction

None of the other answers fix the root cause of the issue. The problem is that when Postgres raises an exception, it poisons future transactions on the same connection. The fix is to rollback the offending transaction: begin ActiveRecord…do something… rescue Exception => e puts “SQL error in #{ __method__ }” ActiveRecord::Base.connection.execute ‘ROLLBACK’ raise e … Read more

Will a using statement rollback a database transaction if an error occurs?

Dispose method for transaction class performs a rollback while Oracle’s class doesn’t. So from transaction’s perspective it’s implementation dependent. The using statement for the connection object on the other hand would either close the connection to the database or return the connection to the pool after resetting it. In either case, the outstanding transactions should … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)