Move database reset above flushing