FIX: do not rollback imports unless data has been changed

This commit is contained in:
Régis Hanol 2014-08-20 11:53:15 +02:00
parent c316894167
commit 7a621d97b9

View file

@ -93,6 +93,7 @@ module Import
def initialize_state def initialize_state
@success = false @success = false
@db_was_changed = false
@current_db = RailsMultisite::ConnectionManagement.current_db @current_db = RailsMultisite::ConnectionManagement.current_db
@current_version = BackupRestore.current_version @current_version = BackupRestore.current_version
@timestamp = Time.now.strftime("%Y-%m-%d-%H%M%S") @timestamp = Time.now.strftime("%Y-%m-%d-%H%M%S")
@ -244,6 +245,8 @@ module Import
"COMMIT;" "COMMIT;"
].join("\n") ].join("\n")
@db_was_changed = true
User.exec_sql(sql) User.exec_sql(sql)
end end
@ -275,7 +278,7 @@ module Import
def rollback def rollback
log "Trying to rollback..." log "Trying to rollback..."
if BackupRestore.can_rollback? if @db_was_changed && BackupRestore.can_rollback?
log "Rolling back..." log "Rolling back..."
BackupRestore.move_tables_between_schemas("backup", "public") BackupRestore.move_tables_between_schemas("backup", "public")
else else